/* ================= UKA-GV Foto ================= */

@font-face {
  font-family: "Barlow";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("fonts/barlow-400.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("fonts/barlow-500.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("fonts/barlow-600.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("fonts/barlow-condensed-600.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  src: url("fonts/barlow-condensed-700.woff2") format("woff2");
}

:root {
  --bg: #0B0C0E;
  --raise: #17191D;
  --raise-2: #1F2228;
  --line: #2A2E35;
  --ink: #F4F5F2;
  --dust: #9CA0A8;
  --hivis: #FFD100;
  --hivis-ink: #0B0C0E;
  --ok: #3ECF6E;
  --warn: #FFA028;
  --bad: #FF5247;
  --plate-bg: rgba(11, 12, 14, 0.74);
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --font: "Barlow", -apple-system, system-ui, sans-serif;
  --font-cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.hidden { display: none !important; }

/* ---------- view switching ---------- */
.screen { display: none; }
body[data-view="perm"]    #perm,
body[data-view="cam"]     #cam,
body[data-view="shot"]    #shot,
body[data-view="gallery"] #gallery,
body[data-view="viewer"]  #viewer,
body[data-view="info"]    #info { display: flex; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: var(--r-m);
  font-family: var(--font);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  background: var(--raise-2);
  padding: 0 20px;
  height: 52px;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; }
.btn-primary { background: var(--hivis); color: var(--hivis-ink); }
.btn-primary svg { stroke: var(--hivis-ink); }
.btn-ghost { background: var(--raise-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger svg { stroke: #fff; }
.btn-xl { height: 64px; font-size: 20px; width: 100%; border-radius: var(--r-l); }
.btn-lg { height: 56px; flex: 1; font-size: 18px; }
.btn-sm { height: 40px; font-size: 15px; padding: 0 14px; border-radius: var(--r-s); }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: rgba(23, 25, 29, 0.72);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.iconbtn:active { transform: scale(0.92); }
.iconbtn[aria-pressed="true"] { background: var(--hivis); color: var(--hivis-ink); }
.iconbtn-danger { color: var(--bad); background: var(--raise-2); width: 56px; height: 56px; }

:is(.btn, .iconbtn, .seg-btn, .shutter, .thumbbtn):focus-visible {
  outline: 3px solid var(--hivis);
  outline-offset: 2px;
}

/* ---------- permission screen ---------- */
.perm-screen {
  flex-direction: column;
  min-height: 100dvh;
  padding: calc(var(--sat) + 32px) 24px calc(var(--sab) + 16px);
}
.perm-inner {
  margin: auto 0;
  width: 100%;
  max-width: 420px;
  align-self: center;
}
.perm-logo {
  width: 180px;
  margin-bottom: 28px;
}
.perm-title {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 44px;
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.perm-sub {
  color: var(--dust);
  margin: 12px 0 28px;
  font-size: 18px;
}
.perm-points {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 32px;
}
.perm-points li {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 14px 16px;
}
.perm-ico {
  display: inline-flex;
  width: 44px;
  height: 44px;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--hivis);
  color: var(--hivis-ink);
}
.perm-points strong { display: block; font-size: 17px; }
.perm-points span:not(.perm-ico) { color: var(--dust); font-size: 15px; }
input[type="text"] {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  border-radius: var(--r-m);
  border: 1.5px solid var(--line);
  background: var(--raise);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 500;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
input[type="text"]:focus { border-color: var(--hivis); }
input[type="text"]::placeholder { color: var(--dust); opacity: 0.7; }
.perm-name { display: block; margin-bottom: 18px; }
.perm-name span {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: var(--dust);
  margin-bottom: 8px;
}
.name-hint { color: var(--bad); font-size: 15px; font-weight: 500; margin: -8px 0 14px; }

.perm-denied {
  margin-top: 24px;
  background: var(--raise);
  border: 1px solid var(--bad);
  border-radius: var(--r-m);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 16px;
}
.perm-footer {
  text-align: center;
  color: var(--dust);
  font-size: 13px;
  padding-top: 16px;
}

/* ---------- camera ---------- */
.cam-screen {
  position: fixed;
  inset: 0;
  background: #000;
}
#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cam-top {
  position: absolute;
  top: calc(var(--sat) + 12px);
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 3;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(11, 12, 14, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 15px;
  font-weight: 500;
}
.pill svg { width: 18px; height: 18px; }
.pill[data-state="search"] { color: var(--warn); }
.pill[data-state="search"] svg { animation: pulse 1.4s ease-in-out infinite; }
.pill[data-state="ok"] { color: var(--ok); }
.pill[data-state="weak"] { color: var(--warn); }
.pill[data-state="off"] { color: var(--bad); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* live stamp plate — mirrors exactly what gets burned into the photo */
.plate {
  position: absolute;
  left: 14px;
  bottom: calc(var(--sab) + 132px);
  max-width: min(78%, 380px);
  display: flex;
  border-radius: 12px;
  overflow: hidden;
  background: var(--plate-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2;
}
.plate-stripe {
  width: 8px;
  flex: none;
  background: repeating-linear-gradient(
    45deg,
    var(--hivis) 0 7px,
    #101113 7px 14px
  );
}
.plate-body {
  padding: 10px 14px 11px;
  min-width: 0;
}
.plate-logo {
  height: 15px;
  width: auto;
  display: block;
  margin-bottom: 7px;
}
.plate-street {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.08;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plate-street.searching {
  color: var(--dust);
  animation: pulse 1.4s ease-in-out infinite;
}
.plate-city {
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 16px;
  color: var(--dust);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plate-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--dust);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cam-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 32px calc(var(--sab) + 22px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
  z-index: 3;
}
.shutter {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 5px solid #fff;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.shutter-core {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: var(--hivis);
  transition: transform 0.1s ease;
}
.shutter:active .shutter-core { transform: scale(0.85); }
.thumbbtn {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: var(--r-s);
  border: 2px solid rgba(255, 255, 255, 0.75);
  background: rgba(23, 25, 29, 0.72);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
}
.thumbbtn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumbbtn img:not(.hidden) + svg { display: none; }

.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 4;
}
.flash.go { animation: flash 0.28s ease-out; }
@keyframes flash { 0% { opacity: 0.9; } 100% { opacity: 0; } }

/* ---------- shot preview ---------- */
.shot-screen {
  position: fixed;
  inset: 0;
  background: #000;
  flex-direction: column;
}
#shotImg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.shot-saved {
  position: absolute;
  top: calc(var(--sat) + 14px);
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--hivis);
  color: var(--hivis-ink);
  font-weight: 600;
  font-size: 16px;
  z-index: 2;
}
.shot-saved svg { width: 20px; height: 20px; stroke: var(--hivis-ink); }
.shot-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px calc(var(--sab) + 18px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
  z-index: 2;
}

/* ---------- bars (gallery / viewer / info) ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--sat) + 10px) 14px 10px;
}
.bar .iconbtn { background: var(--raise); }
.bar-title {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 28px;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-title-sm { font-size: 22px; text-align: center; }
.bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 48px;
  justify-content: flex-end;
}
.bar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent);
}
.bar-overlay .iconbtn { background: rgba(23, 25, 29, 0.72); }

/* ---------- gallery ---------- */
.gallery-screen {
  flex-direction: column;
  min-height: 100dvh;
}
.seg {
  display: flex;
  gap: 6px;
  margin: 4px 14px 12px;
  background: var(--raise);
  border-radius: var(--r-m);
  padding: 5px;
}
.seg-btn {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--dust);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn.active { background: var(--hivis); color: var(--hivis-ink); }

.gallery-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 14px calc(var(--sab) + 110px);
}
.group-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 18px 2px 10px;
}
.group-title {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.group-count {
  color: var(--dust);
  font-size: 15px;
  font-weight: 500;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  border: none;
  border-radius: var(--r-s);
  overflow: hidden;
  background: var(--raise);
  cursor: pointer;
  padding: 0;
}
.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cell-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 8px 6px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  color: #fff;
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.cell-sync {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(11, 12, 14, 0.65);
  color: var(--warn);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cell-sync svg { width: 16px; height: 16px; }
.cell-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(11, 12, 14, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
}
.cell-check svg { width: 16px; height: 16px; stroke: var(--hivis-ink); display: none; }
body.selecting .cell-check { display: flex; }
.cell.selected { outline: 3px solid var(--hivis); outline-offset: -3px; }
.cell.selected .cell-check { background: var(--hivis); border-color: var(--hivis); }
.cell.selected .cell-check svg { display: block; }

.gallery-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--dust);
  padding-bottom: 15dvh;
}
.gallery-empty svg { width: 56px; height: 56px; stroke-width: 1.5; }
.gallery-empty p { font-size: 18px; }

.select-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px calc(var(--sab) + 14px);
  background: var(--raise);
  border-top: 1px solid var(--line);
  z-index: 3;
}
.select-count { font-weight: 600; font-size: 16px; }
.select-actions { display: flex; gap: 10px; }

/* ---------- viewer ---------- */
.viewer-screen {
  position: fixed;
  inset: 0;
  background: #000;
  flex-direction: column;
}
.viewer-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#viewerImg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ---------- info ---------- */
.info-screen {
  flex-direction: column;
  min-height: 100dvh;
}
.info-body {
  padding: 10px 22px calc(var(--sab) + 24px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 480px;
  font-size: 17px;
}
.info-logo {
  width: 150px;
  margin-bottom: 4px;
}
.info-body p { color: var(--ink); }
.info-user {
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 14px 16px;
}
.info-user label {
  display: block;
  font-size: 14px;
  color: var(--dust);
  margin-bottom: 8px;
}
.info-user-row { display: flex; gap: 10px; }
.info-user-row input { flex: 1; height: 48px; }
.info-warn {
  background: var(--raise);
  border: 1px solid var(--line);
  border-left: 4px solid var(--hivis);
  border-radius: var(--r-s);
  padding: 14px 16px;
}
.info-meta { color: var(--dust); font-size: 14px; }

/* ---------- modal + toast ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}
.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 24px 20px 20px;
}
.modal-text { font-size: 18px; font-weight: 500; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sab) + 120px);
  transform: translateX(-50%) translateY(10px);
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: 16px;
  padding: 12px 22px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
  max-width: 86%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
