/* ============================================================
   Shared in-browser camera capture modal
   ============================================================ */

.jb-camera-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

body.jb-camera-open {
  overflow: hidden;
}

.jb-camera-modal__inner {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: clamp(0.75rem, 2.5vw, 1.25rem);
  box-sizing: border-box;
}

.jb-camera-modal__stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.jb-camera-modal__stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

/* Mirror the preview when front camera is active (like FaceTime). */
.jb-camera-modal__stage video.is-user {
  transform: scaleX(-1);
}

/* Square reticle showing where the square crop will land. */
.jb-camera-modal__frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(80vmin, 400px);
  aspect-ratio: 1;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}

/* Cinnabar corner crosshairs via layered borders on the frame itself */
.jb-camera-modal__frame {
  --cross: 22px;
  background:
    linear-gradient(var(--accent, #8c4a2f), var(--accent, #8c4a2f)) top    left  / var(--cross) 2px no-repeat,
    linear-gradient(var(--accent, #8c4a2f), var(--accent, #8c4a2f)) top    left  / 2px var(--cross) no-repeat,
    linear-gradient(var(--accent, #8c4a2f), var(--accent, #8c4a2f)) top    right / var(--cross) 2px no-repeat,
    linear-gradient(var(--accent, #8c4a2f), var(--accent, #8c4a2f)) top    right / 2px var(--cross) no-repeat,
    linear-gradient(var(--accent, #8c4a2f), var(--accent, #8c4a2f)) bottom left  / var(--cross) 2px no-repeat,
    linear-gradient(var(--accent, #8c4a2f), var(--accent, #8c4a2f)) bottom left  / 2px var(--cross) no-repeat,
    linear-gradient(var(--accent, #8c4a2f), var(--accent, #8c4a2f)) bottom right / var(--cross) 2px no-repeat,
    linear-gradient(var(--accent, #8c4a2f), var(--accent, #8c4a2f)) bottom right / 2px var(--cross) no-repeat;
}

.jb-camera-modal__error {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 0.85rem 1.1rem;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-align: center;
  max-width: 80%;
}

.jb-camera-modal__controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 0.25rem 0.5rem;
}

.jb-camera-modal__btn {
  padding: 0.65rem 1rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.jb-camera-modal__btn:hover,
.jb-camera-modal__btn:focus-visible {
  border-color: var(--accent, #8c4a2f);
  color: var(--accent, #8c4a2f);
  outline: none;
}

.jb-camera-modal__cancel {
  justify-self: start;
}

.jb-camera-modal__flip {
  justify-self: end;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.jb-camera-modal__shutter {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.jb-camera-modal__shutter::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
}

.jb-camera-modal__shutter-ring {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fff;
  display: block;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3) inset;
  transition: transform 0.12s ease, background 0.12s ease;
}

.jb-camera-modal__shutter:hover .jb-camera-modal__shutter-ring,
.jb-camera-modal__shutter:focus-visible .jb-camera-modal__shutter-ring {
  transform: scale(0.94);
  background: var(--accent, #8c4a2f);
}

.jb-camera-modal__shutter:active .jb-camera-modal__shutter-ring {
  transform: scale(0.85);
  background: var(--accent, #8c4a2f);
}

@media (prefers-reduced-motion: reduce) {
  .jb-camera-modal__stage video,
  .jb-camera-modal__shutter-ring { transition: none; }
}

/* Narrow screens: tighten the reticle a bit */
@media (max-width: 420px) {
  .jb-camera-modal__frame {
    width: min(85vmin, 340px);
  }
  .jb-camera-modal__btn { padding: 0.55rem 0.75rem; font-size: 0.66rem; }
  .jb-camera-modal__shutter { width: 66px; height: 66px; }
  .jb-camera-modal__shutter-ring { width: 52px; height: 52px; }
}
