/* TrueGlass V4 — the camera page's own styles (D14, D14b).
   v4.css is shared and frozen, so the capture page's pieces live here:
   the classes that replaced capture.js's and capture.html's inline style
   attributes (the page runs under a CSP with no 'unsafe-inline'), the
   sealing-mode gate, and (D14b) the camera surface of sealing mode: the
   whole frame on a dark surface, the round shutter with the mark over
   the image's bottom edge, the "Sealing… tap to cancel" pill in its
   place over the frozen still, the later states as a sheet over the
   still, and the light Sealed screen. Tokens are v4.css's; nothing here
   overrides a slab rule.

   Scope: every D14b rule sits under #main[data-capture-mode="sealing"]
   (or the capture page's app frame, body.app-mode[data-app-page=
   "capture.html"]), so the offline preview, the fixture pages and the
   protected still-path tests (desktop size, offline) see exactly the
   D14 page. Controls never go inside #stage (capture.js replaces its
   children); motion is CSS animation only, so v4.css's reduced-motion
   rule switches all of it off. */

/* ── formerly inline (both modes) ────────────────────────────────────── */
.cam-error-text { margin: 0 0 6px; }
.cam-error-code { margin: 0 0 12px; opacity: 0.7; }
.btn-group.align-center { align-items: center; }
.btn-group .seal-note { margin-left: 12px; }
.seal-note:empty { display: none; }

/* sealing mode: the per-capture location button keeps its grid slot
   (the shutter stays centred) but is neither shown nor focusable */
.camera-controls > .is-placeholder { visibility: hidden; }

/* the shutter's mark is drawn in sealing mode only; offline keeps the
   D14 shutter exactly */
.shutter > .shutter-mark { display: none; }

.seal-cam-note { margin: 12px 0 0; }

/* ── the gate before the camera ──────────────────────────────────────── */
.seal-gate-title { margin-top: 0; }
.seal-gate p { max-width: 40em; }
.seal-gate .btn-group { margin-top: 20px; }
.intro-note-line + .intro-note-line { margin-top: 8px; }
.intro-note-line { margin: 0; }

/* ── the sealing panel's text (both its window and its sheet) ────────── */
.seal-status { margin: 0; font-weight: 500; }
.seal-status-detail { margin: 6px 0 0; }
.seal-code { margin: 6px 0 0; opacity: 0.7; overflow-wrap: anywhere; }
.seal-panel .btn { max-width: 100%; white-space: normal; }
.seal-countdown { margin: 10px 0 0; text-align: center; font-variant-numeric: tabular-nums; }
.sealed-code { overflow-wrap: anywhere; }

/* ══ D14b: the camera page in sealing mode ═══════════════════════════ */

/* The page itself is dark through app.css's opt-in (body.app-surface-dark,
   set by capture-page.js and lifted for the Sealed screen by seal-flow.js),
   which also darkens the slim header. */

#main[data-capture-mode="sealing"] {
  --cap-bg: #000000;
  --cap-region: #0D0F14;
  --cap-ink: #FFFFFF;
  --cap-soft: rgba(255, 255, 255, 0.76);
  --cap-glass: rgba(22, 22, 22, 0.62);
  --cap-line: rgba(255, 255, 255, 0.24);
  --cap-glow: 0 0 0 4px rgba(143, 166, 255, 0.45), 0 0 34px 10px rgba(69, 102, 217, 0.65);
  --cap-rest: 0 2px 12px rgba(0, 0, 0, 0.35);
  /* what sits above the surface: the banner (one or two lines) and the
     slim app header. An upper bound, so the surface never runs below the
     fold; app.css may name the header's height as --app-header-h. */
  --cap-top: calc(var(--app-header-h, 56px) + 48px + env(safe-area-inset-top));
  --cap-h: calc(100vh - var(--cap-top));
  /* the band under the image: the shutter's lower half, the lens row */
  --cap-strip: calc(124px + env(safe-area-inset-bottom));
  --cap-shutter: 84px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: none;
  min-height: var(--cap-h);
  margin: 0;
  padding: 0;
  background: var(--cap-bg);
}
@supports (height: 100svh) {
  #main[data-capture-mode="sealing"] { --cap-h: calc(100svh - var(--cap-top)); }
}
@supports (height: 100dvh) {
  #main[data-capture-mode="sealing"] { --cap-h: calc(100dvh - var(--cap-top)); }
}

/* the page heading, the step strip and the intro's heading stay in the
   document for assistive technology, out of sight */
#main[data-capture-mode="sealing"] > h1,
#main[data-capture-mode="sealing"] > #flow,
#main[data-capture-mode="sealing"] > #intro > h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── the gate: a light card centred on the dark surface ──────────────── */
#main[data-capture-mode="sealing"] > #gate {
  width: calc(100% - 32px);
  max-width: 448px;
  margin: 24px 16px;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
#main[data-capture-mode="sealing"] > #gate .btn-group { gap: 8px; }
#main[data-capture-mode="sealing"] > #gate .btn { border-radius: 12px; }

/* ── the three dark surfaces: camera off, camera on, sealing ─────────── */
#main[data-capture-mode="sealing"] > #intro,
#main[data-capture-mode="sealing"] > #cameraPanel,
#main[data-capture-mode="sealing"] > #sealPanel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 480px;
  min-height: var(--cap-h);
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--cap-bg);
  color: var(--cap-ink);
  overflow: hidden;
}

/* the round control in the shutter's place: a white disc in a white
   ring, the mark inside (the shutter, and "Open camera") */
#main[data-capture-mode="sealing"] .shutter,
#main[data-capture-mode="sealing"] .open-camera-disc {
  display: grid;
  place-items: center;
  width: var(--cap-shutter);
  height: var(--cap-shutter);
  padding: 4px;
  border: 4px solid rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  background: #FFFFFF;
  background-clip: content-box;
  box-shadow: var(--cap-rest);
  transition: transform var(--tg-productive) var(--tg-ease), border-color var(--tg-productive) var(--tg-ease),
    box-shadow var(--tg-productive) var(--tg-ease);
}
#main[data-capture-mode="sealing"] .shutter > .shutter-mark,
#main[data-capture-mode="sealing"] .open-camera-mark {
  display: block;
  width: 46px;
  height: 46px;
  pointer-events: none;
}
#main[data-capture-mode="sealing"] .tg-mark-back,
#main[data-capture-mode="sealing"] .tg-mark-front,
#main[data-capture-mode="sealing"] .tg-mark-cube {
  transform-box: view-box;
  transform-origin: 512px 512px;
}

/* camera off: the note in the image region, "Open camera" in the
   shutter's place with its label, the example link small at the foot */
#main[data-capture-mode="sealing"] > #intro {
  grid-template-rows: minmax(16px, 1fr) auto auto minmax(16px, 1fr) var(--cap-strip);
}
#main[data-capture-mode="sealing"] > #intro::before {
  content: "";
  grid-row: 1 / 5;
  grid-column: 1;
  background: var(--cap-region);
}
#main[data-capture-mode="sealing"] > #intro > p.muted,
#main[data-capture-mode="sealing"] > #intro > #introNote {
  grid-column: 1;
  justify-self: center;
  max-width: 34em;
  margin: 0;
  padding: 0 32px;
  color: var(--cap-soft);
  font-size: 0.875rem;
  line-height: 1.5;
  text-align: center;
}
#main[data-capture-mode="sealing"] > #intro > p.muted { grid-row: 2; }
#main[data-capture-mode="sealing"] > #intro > #introNote { grid-row: 3; margin-top: 10px; }
#main[data-capture-mode="sealing"] #introNote a { color: var(--tg-accent-light); }
#main[data-capture-mode="sealing"] #introNote a:hover { color: #FFFFFF; }
#main[data-capture-mode="sealing"] > #intro > .btn-group { display: contents; }
#main[data-capture-mode="sealing"] #openCamera {
  grid-row: 5;
  grid-column: 1;
  align-self: start;
  justify-self: center;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 0;
  margin-top: calc(var(--cap-shutter) / -2);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--cap-ink);
  font: 500 0.9375rem/1.2 var(--tg-font);
  -webkit-tap-highlight-color: transparent;
}
#main[data-capture-mode="sealing"] #openCamera:hover { background: transparent; color: var(--cap-ink); }
#main[data-capture-mode="sealing"] #openCamera:focus-visible {
  outline: 3px solid var(--tg-accent-light);
  outline-offset: 4px;
  box-shadow: none;
}
#main[data-capture-mode="sealing"] #openCamera:active .open-camera-disc {
  transform: scale(0.92);
  border-color: var(--tg-accent-light);
  box-shadow: var(--cap-glow);
}
#main[data-capture-mode="sealing"] > #intro a.btn {
  grid-row: 5;
  grid-column: 1;
  align-self: end;
  justify-self: center;
  min-height: 32px;
  margin: 0 0 calc(10px + env(safe-area-inset-bottom));
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--cap-soft);
  font-size: 0.8125rem;
  justify-content: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#main[data-capture-mode="sealing"] > #intro a.btn::after { display: none; }
#main[data-capture-mode="sealing"] > #intro a.btn:hover { background: transparent; color: #FFFFFF; }

/* camera on: the stage fills the region above the band, the frame shown
   whole (contain, nothing cropped) and seated on the region's bottom
   edge; the chips over its top; the shutter centred on that edge */
#main[data-capture-mode="sealing"] > #cameraPanel {
  grid-template-rows: auto auto minmax(0, 1fr) var(--cap-strip);
}
#main[data-capture-mode="sealing"] #stage {
  grid-row: 1 / 4;
  grid-column: 1;
  min-height: 0;
  background: transparent;
}
/* a scrim behind the chips; it never takes a tap */
#main[data-capture-mode="sealing"] #stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 112px;
  background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
  pointer-events: none;
}
#main[data-capture-mode="sealing"] #stage > video {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}
/* the requesting, paused and error screens: centred, clickable */
#main[data-capture-mode="sealing"] #stage > .camera-empty {
  position: relative;
  z-index: 2;
  margin: auto;
}
#main[data-capture-mode="sealing"] #camStatus {
  grid-row: 1;
  grid-column: 1;
  align-self: start;
  z-index: 2;
  justify-content: center;
  gap: 6px;
  margin: 12px 12px 0;
  pointer-events: none;
}
#main[data-capture-mode="sealing"] #camStatus .chip {
  padding: 5px 10px;
  border-color: var(--cap-line);
  border-radius: 999px;
  background: var(--cap-glass);
  color: var(--cap-ink);
}
#main[data-capture-mode="sealing"] #camStatus .chip-warn {
  border-color: var(--tg-warning-border);
  border-radius: 12px;
  background: var(--tg-warning-bg);
  color: var(--tg-warning);
  pointer-events: auto;
}
#main[data-capture-mode="sealing"] #sealCamNote {
  grid-row: 2;
  grid-column: 1;
  align-self: start;
  justify-self: center;
  z-index: 2;
  max-width: calc(100% - 24px);
  margin: 8px 12px 0;
  padding: 5px 12px;
  border: 1px solid var(--cap-line);
  border-radius: 14px;
  /* near-opaque, so the note and its link stay readable over any scene
     (D14b fix round 1, finding 4) */
  background: rgba(22, 22, 22, 0.9);
  color: var(--cap-ink);
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: center;
}
/* the link as white as the note's text, told apart by its underline */
#main[data-capture-mode="sealing"] #sealCamNote a {
  color: #FFFFFF;
  text-decoration: underline;
  text-underline-offset: 2px;
}
#main[data-capture-mode="sealing"] #sealCamNote a:hover { text-decoration-thickness: 2px; }

#main[data-capture-mode="sealing"] #shutterRow {
  grid-row: 4;
  grid-column: 1;
  align-self: start;
  z-index: 3;
  gap: 12px;
  margin-top: calc(var(--cap-shutter) / -2);
  padding: 0 12px;
}
#main[data-capture-mode="sealing"] #closeCamera {
  min-height: 40px;
  padding: 0 14px;
  border-color: var(--cap-line);
  border-radius: 999px;
  background: var(--cap-glass);
  color: var(--cap-ink);
  font-size: 0.8125rem;
  justify-content: center;
}
#main[data-capture-mode="sealing"] #closeCamera:hover { background: rgba(22, 22, 22, 0.86); color: #FFFFFF; }
#main[data-capture-mode="sealing"] #lensRow {
  grid-row: 4;
  grid-column: 1;
  align-self: end;
  z-index: 3;
  justify-content: center;
  gap: 8px;
  margin: 0 12px calc(14px + env(safe-area-inset-bottom));
}
#main[data-capture-mode="sealing"] #lensRow .btn {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 14px;
  border-color: var(--cap-line);
  border-radius: 999px;
  background: var(--cap-glass);
  color: var(--cap-ink);
  font-size: 0.8125rem;
  justify-content: center;
}
#main[data-capture-mode="sealing"] #lensRow .btn[aria-pressed="true"] {
  border-color: #FFFFFF;
  background: #FFFFFF;
  color: var(--tg-ink);
  font-weight: 600;
}
#main[data-capture-mode="sealing"] #lensRow .btn[disabled] { opacity: 0.5; }

/* the shutter: a press glows (accent-light ring, soft blue light) and
   the mark's front pane and cube slide into place */
#main[data-capture-mode="sealing"] .shutter {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#main[data-capture-mode="sealing"] .shutter:focus-visible {
  outline: 3px solid var(--tg-accent-light);
  outline-offset: 3px;
  box-shadow: var(--cap-rest);
}
#main[data-capture-mode="sealing"] .shutter:active {
  transform: scale(0.92);
  border-color: var(--tg-accent-light);
  box-shadow: var(--cap-glow);
}
#main[data-capture-mode="sealing"] .shutter.is-pressed { animation: tg-cap-press 650ms var(--tg-ease); }
#main[data-capture-mode="sealing"] .shutter:active .tg-mark-front,
#main[data-capture-mode="sealing"] .shutter.is-pressed .tg-mark-front {
  animation: tg-cap-front-in 450ms var(--tg-ease) both;
}
#main[data-capture-mode="sealing"] .shutter:active .tg-mark-cube,
#main[data-capture-mode="sealing"] .shutter.is-pressed .tg-mark-cube {
  animation: tg-cap-cube-in 450ms 200ms var(--tg-ease) both;
}

/* sealing: the frozen still in the image region, exactly where the live
   frame was; the cancel pill in the shutter's place, the count below */
#main[data-capture-mode="sealing"] > #sealPanel {
  grid-template-rows: minmax(0, 1fr) var(--cap-strip);
}
#main[data-capture-mode="sealing"] .seal-shot {
  grid-row: 1;
  grid-column: 1;
  position: relative;
  display: block;
  min-height: 0;
  margin: 0;
  background: transparent;
}
#main[data-capture-mode="sealing"] .seal-shot img {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}
#main[data-capture-mode="sealing"] .seal-window {
  grid-row: 2;
  grid-column: 1;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px;
}
#main[data-capture-mode="sealing"] .seal-cancel {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-height: 66px;
  margin-top: -33px;
  padding: 0 22px 0 11px;
  border: 2px solid var(--tg-accent-light);
  border-radius: 999px;
  background: rgba(22, 22, 22, 0.74);
  color: #FFFFFF;
  font: 500 0.9375rem/1.25 var(--tg-font);
  text-align: left;
  box-shadow: 0 0 0 4px rgba(143, 166, 255, 0.35), 0 0 30px 8px rgba(69, 102, 217, 0.55);
  animation: tg-cap-breathe 1.1s ease-in-out infinite;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#main[data-capture-mode="sealing"] .seal-cancel:hover { background: rgba(22, 22, 22, 0.88); }
#main[data-capture-mode="sealing"] .seal-cancel:focus-visible { outline: 3px solid #FFFFFF; outline-offset: 3px; }
#main[data-capture-mode="sealing"] .seal-cancel-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #FFFFFF;
}
#main[data-capture-mode="sealing"] .seal-cancel-svg { display: block; width: 28px; height: 28px; }
#main[data-capture-mode="sealing"] .seal-cancel .tg-mark-front { animation: tg-cap-front-in 450ms var(--tg-ease) both; }
#main[data-capture-mode="sealing"] .seal-cancel .tg-mark-cube { animation: tg-cap-cube-in 450ms 200ms var(--tg-ease) both; }
#main[data-capture-mode="sealing"] .seal-window .seal-countdown {
  margin: 12px 0 0;
  color: var(--cap-soft);
  font-size: 0.875rem;
}

/* every later state (working, the passkey wait and its tap, a refusal,
   an error): a sheet over the still's lower edge */
#main[data-capture-mode="sealing"] .seal-sheet {
  grid-row: 1 / 3;
  grid-column: 1;
  align-self: end;
  z-index: 2;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--tg-surface);
  color: var(--tg-ink);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
}
#main[data-capture-mode="sealing"] .seal-sheet > p { margin-bottom: 0; }
#main[data-capture-mode="sealing"] .seal-sheet .seal-status { font-size: 1.0625rem; line-height: 1.35; }
#main[data-capture-mode="sealing"] .seal-sheet .btn-group { display: grid; gap: 10px; margin-top: 16px; }
#main[data-capture-mode="sealing"] .seal-sheet .btn {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  font-weight: 500;
  justify-content: center;
  text-align: center;
}
#main[data-capture-mode="sealing"] .seal-sheet .btn-ghost {
  border-color: transparent;
  background: var(--tg-accent-tint);
  color: var(--tg-accent-ink);
}
#main[data-capture-mode="sealing"] .seal-sheet .btn-ghost:hover { background: #DCE3FA; color: var(--tg-accent-ink); }
#main[data-capture-mode="sealing"] .seal-sheet .seal-tap { min-height: 64px; }

/* ── the Sealed screen: light, the slab centred, two actions, two lines */
#main[data-capture-mode="sealing"][data-capture-view="sealed"] {
  justify-content: flex-start;
  background: var(--tg-page);
}
#main[data-capture-mode="sealing"] > #sealedPanel {
  width: 100%;
  max-width: 480px;
  margin: 0;
  padding: 16px 16px 32px;
  color: var(--tg-ink);
}
#main[data-capture-mode="sealing"] .seal-done-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 4px 0 0;
  color: var(--tg-success);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: 0;
}
#main[data-capture-mode="sealing"] .seal-done-icon { display: inline-flex; }
#main[data-capture-mode="sealing"] .seal-done-icon svg { width: 20px; height: 20px; }
#main[data-capture-mode="sealing"] .sealed-code { margin: 2px 0 0; text-align: center; }
#main[data-capture-mode="sealing"] .sealed-stage {
  display: flex;
  justify-content: center;
  padding: 16px 0 20px;
}
#main[data-capture-mode="sealing"] .sealed-note { margin: 0 0 12px; text-align: center; }
/* app.css's full-width buttons space themselves (10 px between two) */
#main[data-capture-mode="sealing"] .sealed-actions { margin: 0; }
#main[data-capture-mode="sealing"] .sealed-lines {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 16px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  color: var(--tg-faint);
  font-size: 0.75rem;
  text-align: center;
}

/* ── motion (CSS only: v4.css's reduced-motion rule stops all of it) ── */
@keyframes tg-cap-press {
  0%, 35% {
    transform: scale(0.92);
    border-color: #8FA6FF;
    box-shadow: 0 0 0 4px rgba(143, 166, 255, 0.45), 0 0 34px 10px rgba(69, 102, 217, 0.65);
  }
  100% {
    transform: none;
    border-color: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  }
}
@keyframes tg-cap-front-in {
  from { transform: translate(140px, 140px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes tg-cap-cube-in {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes tg-cap-breathe {
  50% { box-shadow: 0 0 0 7px rgba(143, 166, 255, 0.28), 0 0 44px 14px rgba(69, 102, 217, 0.45); }
}
