/* Campor — a portrait camera. Black body, one warm accent: the colour of a
   focus confirmation light. */

:root {
  --bg: #0a0a0b;
  --panel: #141416;
  --panel-2: #1c1c1f;
  --line: #2a2a2e;
  --text: #f2f0ec;
  --dim: #9a978f;
  --accent: #f5b841;
  --accent-ink: #1a1305;
  --danger: #ef6a55;
  --ok: #7fd39a;
  --radius: 14px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 22px; height: 22px; display: block; flex: none; }
[hidden] { display: none !important; }

.app {
  height: 100dvh;
  display: flex; flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
  max-width: 640px; margin: 0 auto;
}

/* ---------- top ---------- */
.top {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; height: 52px; flex: none;
}
.top-right { margin-left: auto; display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); text-decoration: none;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn.on { color: var(--accent); }
.icon-btn.round { background: var(--panel-2); width: 48px; height: 48px; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px; border-radius: 15px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums;
  margin: 0 auto;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.chip[data-phase="ready"] .dot { background: var(--ok); animation: none; }
.chip[data-phase="error"] .dot { background: var(--danger); animation: none; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- viewfinder ---------- */
.finder-wrap {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0 12px;
}
.finder {
  position: relative;
  aspect-ratio: 3 / 4;
  height: 100%; max-width: 100%;
  border-radius: 10px; overflow: hidden;
  background: #000;
}
@supports not (aspect-ratio: 3 / 4) { .finder { width: 75vh; } }
.finder canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.finder.mirror canvas { transform: scaleX(-1); }
/* Kept in the document and playing: some browsers stop decoding a video
   that is display:none, and then there is nothing to draw. */
.finder video { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; left: 0; top: 0; }

.reticle {
  position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border: 1.5px solid var(--accent); border-radius: 8px;
  pointer-events: none;
  transition: left .25s ease, top .25s ease, opacity .5s ease, transform .25s ease;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}
.reticle.person { border-radius: 50%; width: 84px; height: 84px; margin: -42px 0 0 -42px; }
.reticle.fade { opacity: .0; }

.view-label {
  position: absolute; left: 12px; top: 12px;
  padding: 4px 10px; border-radius: 12px; font-size: 12px;
  background: rgba(0,0,0,.55); color: var(--accent);
  pointer-events: none;
}
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .35s ease-out; }
@keyframes flash { 0% { opacity: .7; } 100% { opacity: 0; } }

.cam-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(10,10,11,.86); text-align: center; padding: 24px;
}
.cam-overlay p { margin: 0 0 6px; color: var(--dim); }

/* ---------- controls ---------- */
.controls { flex: none; padding: 8px 12px 6px; }

.zoom {
  display: flex; justify-content: center; align-items: center; gap: 4px;
  margin-bottom: 8px;
}
.zoom button[data-zoom] {
  min-width: 42px; height: 32px; padding: 0 8px; border-radius: 16px;
  font-size: 13px; font-weight: 600; color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.zoom button[data-zoom] small { font-size: 10px; margin-left: 1px; }
.zoom button[data-zoom].on { background: var(--panel-2); color: var(--accent); }

.info-dot { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; color: var(--dim); border-radius: 50%; flex: none; }
.info-dot svg { width: 17px; height: 17px; }
.info-dot:hover { color: var(--text); }

.dial { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px 8px; }
.dial-tabs { display: flex; gap: 2px; }
.dial-tabs button {
  flex: 1; height: 34px; border-radius: 10px;
  font-size: 13px; color: var(--dim);
}
.dial-tabs button b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 2px; }
.dial-tabs button.on { background: var(--panel-2); color: var(--text); }
.dial-tabs button.on b { color: var(--accent); }

.dial-panel { padding: 4px 2px 0; }
.row { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.row input[type=range] { flex: 1; min-width: 0; }
.end { font-size: 11.5px; color: var(--dim); flex: none; }
.value { min-width: 44px; text-align: right; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; font-size: 14px; }
.hint { margin: 2px 2px 0; font-size: 12px; color: var(--dim); }
.subject-line { flex: 1; min-width: 0; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  height: 28px; padding: 0 12px; border-radius: 14px;
  background: var(--panel-2); color: var(--dim); font-size: 12.5px; font-weight: 600; flex: none;
}
.pill.on { background: var(--accent); color: var(--accent-ink); }

input[type=range] {
  -webkit-appearance: none; appearance: none; background: transparent; height: 32px; margin: 0;
}
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9px; border-radius: 50%;
  background: var(--text); border: 3px solid var(--accent);
}
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 3px solid var(--accent); }

.shutter-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 10px 8px 4px;
}
.shutter-row .thumb { justify-self: start; }
.shutter-row #flip { justify-self: end; }
.thumb {
  width: 48px; height: 48px; border-radius: 10px;
  background: var(--panel-2) center / cover no-repeat; border: 2px solid var(--line);
}
.shutter {
  width: 72px; height: 72px; border-radius: 50%;
  border: 4px solid var(--text); padding: 4px;
  display: flex; align-items: center; justify-content: center;
}
.shutter span { width: 100%; height: 100%; border-radius: 50%; background: var(--text); transition: transform .1s ease; }
.shutter:active span { transform: scale(.88); background: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 21px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn svg { width: 18px; height: 18px; }
.btn.ghost { background: var(--panel-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }

/* ---------- settings sheet ---------- */
.scrim, .info-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; }
.sheet, .info-sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 520px; max-height: 86dvh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 10px 18px calc(18px + var(--safe-b));
  z-index: 21; user-select: text; -webkit-user-select: text;
}
.sheet-head, .info-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head h2, .info-header h3 { margin: 8px 0; font-size: 17px; font-weight: 650; }
.info-close { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.info-body { color: #d6d3cc; font-size: 14.5px; line-height: 1.55; }
.info-body p { margin: 0 0 10px; }
.info-sheet { z-index: 31; }
.info-scrim { z-index: 30; }

.field { margin: 14px 0; }
.label { display: flex; align-items: center; gap: 2px; font-size: 13px; color: var(--dim); margin-bottom: 6px; }
.seg { display: flex; background: var(--panel-2); border-radius: 12px; padding: 3px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 7px 0; border-radius: 9px; font-size: 13.5px; color: var(--dim); cursor: pointer; }
.seg input:checked + span { background: var(--bg); color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.toggle { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 14.5px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.version-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--dim); }

/* ---------- viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 25; background: #000;
  display: flex; flex-direction: column;
  padding: var(--safe-t) 0 var(--safe-b);
}
.viewer-top { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; color: var(--dim); font-size: 13px; }
.viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 4px; }
.viewer-stage img { max-width: calc(100% - 96px); max-height: 100%; object-fit: contain; border-radius: 6px; }
.viewer-actions { display: flex; justify-content: center; gap: 8px; padding: 12px; flex-wrap: wrap; }

/* ---------- update bar (same as the other apps) ---------- */
#update-bar {
  position: fixed; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%);
  z-index: 40; display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 22px;
  padding: 6px 8px 6px 16px; font-size: 13.5px; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
#update-go { background: var(--accent); color: var(--accent-ink); border-radius: 16px; padding: 5px 12px; font-weight: 600; }
#update-later { color: var(--dim); padding: 5px 8px; }

/* A short phone: give the picture the room, tighten the rest. */
@media (max-height: 700px) {
  .top { height: 44px; }
  .controls { padding-top: 4px; }
  .zoom { margin-bottom: 4px; }
  .shutter { width: 62px; height: 62px; }
  .shutter-row { padding-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .reticle, .shutter span { transition: none; }
  .chip .dot { animation: none; }
}
