/* MERAQ Camera - Designsystem aus 03_Designreferenzen/README.md.
   Layout zuerst fuer iPhone SE 2020 (375 x 667), dann aufwaerts. */

:root {
  --bg-deep: #061522;
  --bg-soft: #0A2031;
  --action: #FF8A45;
  --action-secondary: #C87949;
  --text: #FFFFFF;
  --text-muted: #A7BACB;
  --text-dim: #7C93A6;
  --glass: rgba(12, 32, 48, 0.72);
  --glass-line: rgba(167, 186, 203, 0.24);
  --warn: #F2C14E;
  --error: #FF7A6B;
  --radius: 16px;
  --tap: 44px;
  --gap: 12px;
}

* { box-sizing: border-box; }

/* display-Regeln der Komponenten duerfen [hidden] nicht aushebeln */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: linear-gradient(170deg, var(--bg-deep), var(--bg-soft));
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { overflow: hidden; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Bildschirme ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

body[data-screen="start"]    #screen-start,
body[data-screen="lock"]     #screen-lock,
body[data-screen="camera"]   #screen-camera,
body[data-screen="gallery"]  #screen-gallery,
body[data-screen="settings"] #screen-settings,
body[data-screen="info"]     #screen-info { display: flex; }

/* ---------- Start ---------- */

.start-inner {
  margin: auto;
  width: 100%;
  max-width: 420px;
  padding: 24px 20px;
  overflow-y: auto;
  max-height: 100%;
  text-align: center;
}

.brand-mark {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.wordmark {
  margin: 16px 0 4px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.wordmark span {
  display: block;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.34em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.lead {
  color: var(--text-muted);
  margin: 12px 0 22px;
}

.facts {
  margin: 24px 0 12px;
  padding: 0;
  list-style: none;
  text-align: left;
  color: var(--text-dim);
  font-size: 14px;
}

.facts li {
  padding: 8px 0 8px 18px;
  position: relative;
  border-top: 1px solid var(--glass-line);
}

.facts li::before {
  content: "";
  position: absolute;
  left: 0; top: 17px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--action-secondary);
}

.hint {
  font-size: 13px;
  color: var(--text-dim);
  margin: 12px 0 0;
}

/* ---------- Buttons ---------- */

.btn {
  min-height: var(--tap);
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  width: 100%;
  background: var(--action);
  color: #21100A;
  font-weight: 650;
  border-color: var(--action);
}

.btn-quiet {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--glass-line);
}

.btn-small {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 14px;
  width: auto;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.zoom-btn:focus-visible,
.capture-btn:focus-visible,
.thumb-btn:focus-visible,
.mode-btn:focus-visible,
.tap-layer:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

/* ---------- Hinweise ---------- */

.notice {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  text-align: left;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  margin: 16px 0;
}

.notice-error { border-color: var(--error); color: var(--error); }
.notice-warn  { border-color: rgba(242, 193, 78, 0.5); color: var(--warn); }

/* ---------- Kamera ---------- */

#screen-camera { padding: 0; }

.viewfinder {
  position: absolute;
  inset: 0;
  background: #000;
  overflow: hidden;
}

#preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
  transition: transform 180ms ease-out;
}

.tap-layer {
  position: absolute;
  inset: 0;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: crosshair;
}

.target-ring {
  position: absolute;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border: 2px solid var(--action);
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 18px rgba(255, 138, 69, 0.35);
  pointer-events: none;
  animation: ring-in 260ms ease-out;
}

@keyframes ring-in {
  from { transform: scale(1.35); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.hud {
  position: absolute;
  left: 0; right: 0;
  padding: 12px;
  display: flex;
  gap: var(--gap);
  pointer-events: none;
}

.hud > * { pointer-events: auto; }

.hud-top {
  top: env(safe-area-inset-top);
  align-items: flex-start;
}

.hud-bottom {
  bottom: env(safe-area-inset-bottom);
  flex-direction: column;
  align-items: stretch;
}

.status-chip {
  flex: 1;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  padding: 8px 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.status-headline {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.status-guidance {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  color: var(--text);
  font-size: 17px;
  font-style: italic;
  font-family: Georgia, serif;
  cursor: pointer;
}

/* Zoomleiste */

.zoom-rail {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.zoom-btn {
  min-width: var(--tap);
  min-height: 38px;
  padding: 4px 12px;
  border-radius: 19px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  color: var(--text-muted);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.zoom-btn[aria-pressed="true"] {
  background: var(--action);
  border-color: var(--action);
  color: #21100A;
  font-weight: 650;
}

.zoom-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

.zoom-btn .digital {
  display: block;
  font-size: 9px;
  letter-spacing: 0.12em;
}

/* Bedienzeile */

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--gap);
}

.capture-btn {
  justify-self: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.capture-ring {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--text);
  transform: scale(0.82);
  transition: transform 120ms ease-out, background-color 120ms ease-out;
}

.capture-btn:active .capture-ring { transform: scale(0.7); }
.capture-btn[disabled] { opacity: 0.5; }
.capture-btn[data-busy="true"] .capture-ring { background: var(--action); }

.thumb-btn {
  justify-self: start;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
}

.thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { font-size: 14px; }

.mode-btn {
  justify-self: end;
  min-height: var(--tap);
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  text-align: center;
}

.mode-btn strong { display: block; font-size: 13px; color: var(--text); }
.mode-btn[aria-pressed="true"] strong { color: var(--action); }

.confirm-bar {
  background: var(--glass);
  border: 1px solid var(--action-secondary);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.confirm-bar p { margin: 0 0 10px; color: var(--text-muted); }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

.toast {
  margin: 10px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  padding: 8px 12px;
}

/* ---------- Galerie / Info ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 12px;
  border-bottom: 1px solid var(--glass-line);
}

.bar h2 { font-size: 16px; margin: 0; }

#screen-gallery, #screen-info, #screen-settings { overflow-y: auto; }
#screen-gallery > .notice, .prose { margin: 12px; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 0 12px 24px;
}

.gallery-grid button {
  position: relative;
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 1px solid var(--glass-line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--glass);
  cursor: pointer;
}

.gallery-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gallery-grid .tag {
  position: absolute;
  left: 4px; bottom: 4px;
  background: rgba(6, 21, 34, 0.8);
  color: var(--text);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
}

.empty-note { color: var(--text-dim); text-align: center; padding: 24px; }

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(4, 12, 20, 0.9);
  display: flex;
  align-items: flex-end;
  z-index: 10;
}

.sheet-inner {
  width: 100%;
  max-height: 92%;
  overflow-y: auto;
  background: var(--bg-soft);
  border-top: 1px solid var(--glass-line);
  border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

.sheet-inner h3 { margin: 0 0 12px; font-size: 16px; }
.sheet-inner img { width: 100%; border-radius: 12px; display: block; }

.detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 13px;
  margin: 14px 0;
}

.detail-meta dt { color: var(--text-dim); }
.detail-meta dd { margin: 0; }

.sheet-actions { display: grid; gap: 8px; }

.prose h3 { font-size: 15px; margin: 20px 0 8px; color: var(--action); }
.prose ul, .prose ol { margin: 0; padding-left: 20px; color: var(--text-muted); font-size: 14px; }
.prose li { margin-bottom: 6px; }
.prose { padding-bottom: 32px; }

/* ---------- Kleine Geraete: iPhone SE 2020 ---------- */

@media (max-height: 700px) {
  .brand-mark { width: 64px; height: 64px; }
  .wordmark { font-size: 24px; margin-top: 10px; }
  .lead { margin: 8px 0 16px; font-size: 15px; }
  .facts { margin: 16px 0 8px; font-size: 13px; }
  .capture-btn { width: 64px; height: 64px; }
  .thumb-btn { width: 46px; height: 46px; }
  .zoom-rail { margin-bottom: 10px; }
  .hud { padding: 8px; }
}

@media (max-width: 380px) {
  .zoom-rail { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; }
  .zoom-btn { flex: 0 0 auto; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Modi, Aufnahme-Overlays, Einstellungen ---------- */

.start-actions { display: grid; gap: 8px; margin-top: 8px; }

.top-buttons { display: flex; gap: 8px; }

/* Moduswahl */

.mode-rail {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 2px 10px;
  scrollbar-width: none;
}

.mode-rail::-webkit-scrollbar { display: none; }

.mode-chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 17px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.mode-chip[aria-selected="true"] {
  background: var(--action-secondary);
  border-color: var(--action);
  color: var(--text);
  font-weight: 600;
}

.mode-chip[disabled] { opacity: 0.4; cursor: not-allowed; }

/* Dokumentrahmen */

.doc-frame {
  position: absolute;
  inset: 12% 8%;
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  pointer-events: none;
}

/* Teleprompter */

.teleprompter {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 22%;
  max-height: 34%;
  overflow-y: auto;
  background: rgba(6, 21, 34, 0.72);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  padding: 12px 14px;
  pointer-events: none;
}

.teleprompter p {
  margin: 0;
  font-size: 17px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Aufnahmeanzeige */

.rec-badge {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 68px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(6, 21, 34, 0.85);
  border: 1px solid var(--error);
  border-radius: 18px;
  padding: 5px 12px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--error);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.25; } }

.rec-lock {
  color: var(--warn);
  border-left: 1px solid var(--glass-line);
  padding-left: 8px;
}

.capture-btn[data-recording="true"] { border-color: var(--error); }
.capture-btn[data-recording="true"] .capture-ring {
  background: var(--error);
  border-radius: 10px;
  transform: scale(0.55);
}

/* Fortschritt bei Nacht / Serie */

.progress-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(78%, 300px);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.progress-overlay p { margin: 0 0 10px; font-size: 14px; }

.progress-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(167, 186, 203, 0.25);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--action);
  transition: width 120ms linear;
}

/* QR-Ergebnis */

.code-card {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: var(--glass);
  border: 1px solid var(--action);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.code-kind { margin: 0 0 4px; font-size: 12px; color: var(--action); }
.code-value {
  margin: 0 0 10px;
  font-size: 14px;
  word-break: break-all;
  max-height: 5.2em;
  overflow-y: auto;
}
.code-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* 3D-Reihe */

.series-guide {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(env(safe-area-inset-top) + 104px);
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: center;
  pointer-events: none;
}

.series-guide p { margin: 0 0 8px; font-size: 13px; }

.series-dots { display: flex; gap: 6px; justify-content: center; }

.series-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--glass-line);
}

.series-dots span[data-done="true"] { background: var(--action); border-color: var(--action); }

/* Pro-Panel */

.pro-panel {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
}

.pro-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.pro-row input[type="range"] { flex: 1; accent-color: var(--action); }
.pro-note { margin: 8px 0 0; font-size: 12px; color: var(--text-dim); }

/* Einstellungen */

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--glass-line);
  font-size: 14px;
  min-height: var(--tap);
}

.switch-row small {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}

.switch-row input[type="checkbox"] {
  width: 26px;
  height: 26px;
  accent-color: var(--action);
  flex: 0 0 auto;
}

#screen-settings textarea {
  width: 100%;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 10px 12px;
  resize: vertical;
}

#screen-settings .btn { width: 100%; margin-top: 8px; }

.pin-input {
  width: 100%;
  max-width: 180px;
  margin: 12px auto;
  display: block;
  text-align: center;
  letter-spacing: 0.5em;
  font-size: 24px;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-line);
  background: var(--glass);
  color: var(--text);
  font-family: inherit;
}

.pin-small {
  max-width: 110px;
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.3em;
}

/* Galerie-Detail */

#detail-video { width: 100%; border-radius: 12px; display: block; background: #000; }
.compare { margin-top: 10px; }
.gallery-grid .tag.video { background: rgba(255, 122, 107, 0.85); color: #21100A; }

@media (max-height: 700px) {
  .mode-rail { padding-bottom: 8px; }
  .teleprompter { top: 18%; max-height: 28%; }
  .teleprompter p { font-size: 15px; }
}
