/* The 4-step flow (app/index.html), on top of shared/theme.css and common.css. "Tachado" style:
   ink ground, cream text, lime as the single accent (primary action, current step, focus),
   hairline dividers instead of boxed cards, redaction bars as the motif. Phone first. */

.flow-body { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; }

/* ---------- Header extras: privacy badge, stepper, progress line (the header itself is common.css) ---------- */
.top::after { content: ''; position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; background: var(--lime); }
/* Privacy badge: wiggles now and then until it is opened */
button.lock { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: 0 .75rem; background: none; cursor: pointer;
  border: 0; border-radius: 0; font-family: var(--mono); font-size: .75rem; letter-spacing: .02em; color: var(--lime); white-space: nowrap; }
button.lock:hover { color: var(--cream); }
/* Narrow phones: Safari sets the badge text a little wider than Chrome; tighter padding keeps the header on screen. */
@media (max-width: 24rem) { button.lock { padding: 0 .375rem; gap: .3rem; } }
button.lock.wiggle svg { animation: lock-wiggle 5s ease-in-out 1s infinite; transform-origin: 50% 60%; }
/* 5 s cycle: ~3.6 s at rest, then grow -> shake left/right -> shrink back */
@keyframes lock-wiggle {
  0%, 72%, 100% { transform: scale(1) rotate(0); }
  77% { transform: scale(1.45) rotate(0); }
  80% { transform: scale(1.45) rotate(-18deg); }
  83% { transform: scale(1.45) rotate(18deg); }
  86% { transform: scale(1.45) rotate(-14deg); }
  89% { transform: scale(1.45) rotate(10deg); }
  92% { transform: scale(1.45) rotate(0); }
}

/* Stepper */
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem; }
.steps li { display: flex; flex-direction: column; gap: .125rem; padding: .5rem 0 .625rem; border-top: 3px solid var(--line-2);
  font-family: var(--mono); font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); cursor: default; }
.steps li b { font-weight: 500; overflow-wrap: anywhere; }
.steps li.done, .steps li.reach { cursor: pointer; color: var(--soft); }
.steps li.done { border-top-color: var(--cream); }
.steps li.reach { border-top-color: #66645d; }
.steps li.done:hover, .steps li.reach:hover { color: var(--lime); }
.steps li.cur { border-top-color: var(--lime); color: var(--cream); }
.steps li.cur span { color: var(--lime); }
@media (min-width: 40rem) { .steps li { flex-direction: row; gap: .625rem; align-items: baseline; font-size: .75rem; } }

/* Checking a photo: a thin line runs under the header */
body.busy .top::after { width: 100%; animation: busy 1.1s ease-in-out infinite; transform-origin: left; }
@keyframes busy { 0% { transform: scaleX(0); } 70% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* ---------- Page ---------- */
.flow { max-width: calc(60rem + 2 * var(--gutter)); margin-inline: auto; padding: 1.75rem var(--gutter) 2rem; display: block; }
.step > .eyebrow { margin-bottom: .5rem; }
.step h2 { font-size: clamp(2.25rem, 9vw, 3.75rem); line-height: .9; font-weight: 900; font-stretch: 70%; text-transform: uppercase;
  letter-spacing: -.01em; text-wrap: balance; overflow-wrap: break-word; margin-bottom: .75rem; }
.step .lede { font-size: 1.0625rem; line-height: 1.55; max-width: 38rem; margin-bottom: 1.5rem; }
.step h3 { margin: 1.5rem 0 .5rem; font-size: .8125rem; font-weight: 500; letter-spacing: .08em; }
.step .muted { color: var(--mute); }
.hint { margin: .625rem 0 0; font-family: var(--mono); font-size: .75rem; letter-spacing: .02em; color: var(--mute); text-align: left; }
.lbl { display: block; margin: 1.5rem 0 .5rem; }

.step h2 + .split, .step .lede + .split { margin-top: 1.25rem; }
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem 3rem; align-items: start; }
@media (min-width: 56rem) {
  .split { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .split-side > h3:first-child { margin-top: 0; }
}

/* ---------- Step 1: photos ---------- */
.slots { display: grid; gap: 1.5rem; }
@media (min-width: 36rem) { .slots { grid-template-columns: 1fr 1fr; gap: 1.5rem 2rem; } }
.slot { border-top: 1px solid var(--line); padding-top: 1rem; min-width: 0; }
.slot .empty { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .375rem;
  aspect-ratio: 85.6 / 54; padding: 1rem; background: var(--panel); border: 2px dashed #5a5851; color: var(--mute); text-align: center; cursor: pointer; overflow: hidden; }
.slot .empty:hover { border-color: var(--lime); }
.slot .empty:focus-within { outline: var(--ring); outline-offset: 3px; }
.slot .empty strong { font-size: 1.75rem; line-height: 1; font-weight: 900; font-stretch: 70%; text-transform: uppercase; color: var(--cream); }
.slot .empty svg { color: var(--lime); }
.slot .empty span { font-family: var(--mono); font-size: .75rem; letter-spacing: .02em; max-width: 18rem; }
.slot .empty input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.slot .empty.has-sample { overflow: hidden; }
.slot .empty .ghost { position: absolute; inset: 10%; width: 80%; height: 80%; object-fit: contain; opacity: .12; pointer-events: none; }
.slot .empty > :not(.ghost):not(input) { position: relative; }
.slot .empty .req-asked { color: var(--lime); font-weight: 600; }
.slot .gal { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; margin-top: .25rem;
  font-family: var(--mono); font-size: .8125rem; letter-spacing: .02em; color: var(--soft); cursor: pointer; }
.slot .gal:hover { color: var(--lime); }
.slot .gal:focus-within { outline: var(--ring); outline-offset: -2px; }
.slot .gal input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.slot .thumb { display: block; width: 100%; height: auto; border-radius: var(--radius-img); box-shadow: 0 0 0 1px var(--line-2); }
.slot-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; padding-top: .75rem; }
.slot-bar .t { font-size: .8125rem; letter-spacing: .04em; text-transform: uppercase; color: var(--lime); }
.slot-bar .row { gap: .5rem; }
#photo-status { margin-top: 1rem; padding: .75rem 1rem; border-left: 4px solid var(--warn); background: var(--panel); }

/* Document version: a disclosure between hairlines */
.tpl-box { margin-top: 1.5rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tpl-box summary { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; min-height: 3.25rem; padding: .5rem 0;
  list-style: none; cursor: pointer; font-family: var(--mono); font-size: .8125rem; letter-spacing: .02em; color: var(--soft); }
.tpl-box summary::-webkit-details-marker { display: none; }
.tpl-box summary::after { content: '+'; flex: none; margin-left: auto; font-size: 1.25rem; color: var(--lime); }
.tpl-box[open] summary::after { content: '−'; }
.tpl-box summary:hover { color: var(--cream); }
.tpl-box[open] { padding-bottom: 1rem; }
.tpl-auto { margin-left: .25rem; padding: 1px .5rem; background: var(--lime); color: var(--ink); font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; vertical-align: 1px; }
.tpl-actions { margin-top: .75rem; }
.tpl-pv { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: .75rem; }
.tpl-pv figure { margin: 0; }
.tpl-pv-open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.tpl-pv img { display: block; width: 100%; height: auto; aspect-ratio: 1012 / 638; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5)); }
.tpl-pv figcaption { margin-top: .25rem; font-family: var(--mono); font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--mute); }
.tpl-pv-hint { margin: .5rem 0 0; font-family: var(--mono); font-size: .75rem; }
#tpl-note { margin-top: .5rem; font-size: .875rem; }
.req-cta { margin-top: 1.5rem; font-family: var(--mono); font-size: .8125rem; }
.req-cta a { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- Preview canvases (light card on dark ground) ---------- */
.pv { position: relative; }
canvas.preview { display: block; width: 100%; height: auto; border-radius: var(--radius-img); box-shadow: 0 0 0 1px var(--line-2), 0 14px 36px rgba(0, 0, 0, .55); }
.pv canvas.zones { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.final { display: grid; gap: 1rem; }
.pv-sticky { position: sticky; top: 7rem; z-index: 5; background: var(--ink); padding: .5rem 0 .75rem; margin-inline: -2px; }
.pv-sticky .seg { margin-bottom: .75rem; }
.pv-sticky .pv { cursor: crosshair; }
@media (max-height: 700px) and (max-width: 55.99rem) { .pv-sticky { position: static; } }
@media (min-width: 56rem) { .pv-sticky { top: 7.5rem; } }

/* ---------- Step 2: fields. Covering a field = a cream bar closes over its switch ---------- */
#fields h3 { margin: 1.25rem 0 0; padding-bottom: .5rem; border-bottom: 1px solid var(--line-2); color: var(--mute); }
#fields h3:first-child { margin-top: 0; }
.fld { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; padding: .625rem 0; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .15s, box-shadow .15s; }
.fld .nm { display: flex; flex-direction: column; gap: .125rem; font-size: 1.0625rem; font-weight: 700; line-height: 1.25; min-width: 0; }
.fld .nm small { font-family: var(--mono); font-size: .6875rem; font-weight: 400; letter-spacing: .02em; color: var(--soft); }
.fld .nm small::before { content: '■ '; color: var(--cream); }
.fld .nm small.ok { color: var(--mute); }
.fld .nm small.ok::before { content: '□ '; color: var(--mute); }
.fld:has(input:checked) { box-shadow: inset 3px 0 0 var(--cream); padding-left: .875rem; }
.fld.flash { background: rgba(215, 255, 58, .12); }
.fld.req-extra { background: rgba(255, 180, 84, .08); box-shadow: inset 3px 0 0 var(--warn); padding-left: .875rem; }
.fld.req-extra:has(input:checked) { box-shadow: inset 3px 0 0 var(--cream); }
.switch { position: relative; flex: none; width: 3.5rem; height: 2.25rem; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border: 2px dashed #6a6860; transition: border-color .15s; pointer-events: none; }
.switch i::before { content: ''; position: absolute; inset: 3px; background: var(--cream); transform: scaleX(0); transform-origin: left; transition: transform .2s ease; }
.switch input:checked + i { border: 1.5px solid var(--cream); }
.switch input:checked + i::before { transform: scaleX(1); }
.switch input:focus-visible + i { outline: var(--ring); outline-offset: 3px; }
.switch:hover i { border-color: var(--lime); }

/* ---------- Step 3: purpose ---------- */
.purpose-form { display: flex; flex-direction: column; gap: 1rem; }
#purpose, #recipient { font-size: 1rem; } /* 16px avoids iOS auto-zoom on focus */
#purpose { min-height: 3.5rem; font-size: 1.125rem; font-weight: 600; }
.purpose-form .lbl { margin: .5rem 0 0; }

/* ---------- Step 4: share ---------- */
.summary { margin: 1rem 0; padding: .75rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .8125rem; line-height: 1.6; color: var(--soft); overflow-wrap: anywhere; }
.share-actions { display: grid; gap: .75rem; }
#out-status { margin-top: 1rem; }
.req-send { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.req-send h3 { margin-top: 0; color: var(--cream); font-size: 1.125rem; letter-spacing: 0; font-weight: 800; }
.req-send p { margin: .5rem 0; }
.req-send .req-send-btn { margin-top: 1rem; text-align: center; overflow-wrap: anywhere; }

/* ---------- Bottom bar: Back + the one primary action ---------- */
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--ink); border-top: 1px solid var(--line); }
.bottom-in { display: flex; gap: .75rem; max-width: calc(60rem + 2 * var(--gutter)); margin-inline: auto; padding: .75rem var(--gutter); padding-bottom: max(.75rem, env(safe-area-inset-bottom)); }
.bottom-in .btn { min-height: 3.25rem; }
.bottom-in #nav-back { flex: 0 0 auto; min-width: 6rem; }
.bottom-in #nav-next { flex: 1; }
.bottom-bar .invisible { display: none; } /* step 1 has no Back button: the main button takes the full width */
@media (min-width: 56rem) { .bottom-in #nav-next { flex: 0 1 22rem; margin-left: auto; } }

/* ---------- Full-screen framing ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: #000; color: var(--cream); display: flex; flex-direction: column; }
.ov-head { padding: .75rem var(--gutter) .5rem; padding-top: max(.75rem, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: .25rem; }
.ov-head strong { font-size: 1.5rem; line-height: 1; font-weight: 900; font-stretch: 70%; text-transform: uppercase; }
.ov-head span { font-family: var(--mono); font-size: .75rem; letter-spacing: .02em; color: var(--soft); }
.ov-canvas { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: .5rem; }
.ov-canvas canvas { border-radius: 4px; }
.ov-bar { display: flex; gap: .375rem; padding: .625rem var(--gutter); padding-bottom: max(.625rem, env(safe-area-inset-bottom)); background: var(--ink); border-top: 1px solid var(--line); }
.ov-bar .btn { flex: 1; min-width: 0; min-height: 3rem; padding: .5rem .25rem; font-size: .875rem; font-weight: 700; }
.ov-bar .btn-primary { flex: 1.3; }

/* ---------- Dialogs (decision, privacy) ---------- */
.decision { border-color: var(--lime); }
.decision h2 { color: var(--cream); }
.decision p { margin: 0 0 1rem; font-size: 1rem; }
.decision-photo { display: block; width: 100%; height: auto; border-radius: var(--radius-img); margin-bottom: 1rem; }
.decision-actions { display: grid; gap: .5rem; }
.privacy h2 { font-size: 1.75rem; }
.privacy p, .privacy li { font-size: .9375rem; line-height: 1.55; }
.privacy ul { display: grid; gap: .375rem; margin: .75rem 0 1rem; }
.privacy li { padding-left: 1.25rem; position: relative; }
.privacy li::before { content: '■'; position: absolute; left: 0; color: var(--lime); font-size: .625rem; top: .4em; }
.privacy a { display: inline-flex; align-items: center; min-height: 44px; color: var(--lime); }
.privacy #privacy-close { margin-top: .75rem; }

/* ---------- Zoom viewer (reference pictures) ---------- */
.zoom-viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #000; overflow: hidden; touch-action: none; display: none; }
.zoom-viewer[open] { display: flex; align-items: center; justify-content: center; }
.zoom-viewer::backdrop { background: #000; }
.zoom-img { max-width: 96vw; max-height: 90dvh; transform-origin: center; user-select: none; -webkit-user-drag: none; will-change: transform; }
.zoom-close { position: absolute; top: max(.75rem, env(safe-area-inset-top)); right: .75rem; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.125rem; background: var(--cream); color: var(--ink); border: 0; border-radius: 0; cursor: pointer; }

/* ---------- Request link panel (what is asked, by whom) ---------- */
.req-invalid { margin: 0 0 1rem; padding: .75rem 1rem; border-left: 4px solid var(--warn); background: var(--panel); }
.req-panel { margin: 0 0 1.75rem; padding: 1rem 0 1rem 1rem; border-left: 4px solid var(--lime); }
.req-panel .req-title { margin: 0 0 .5rem; font-size: 1.5rem; line-height: 1; font-weight: 900; font-stretch: 70%; text-transform: uppercase; overflow-wrap: anywhere; }
.req-panel p { margin: .5rem 0; overflow-wrap: anywhere; }
.req-purpose { font-weight: 700; }
.req-lead.warn { color: var(--warn); font-weight: 600; }
.req-lead.ok { color: var(--ok); }
.req-extras { margin: .5rem 0 .75rem; display: grid; gap: .5rem; }
.req-extra-row { display: flex; gap: .75rem; align-items: flex-start; padding: .75rem; border: 2px dashed var(--warn); cursor: pointer; }
.req-extra-row.accepted { border-style: solid; border-color: var(--ok); }
.req-extra-row input { width: 1.25rem; height: 1.25rem; margin-top: .125rem; accent-color: var(--lime); }
.req-extra-row .req-state { display: block; font-family: var(--mono); font-size: .75rem; color: var(--warn); }
.req-extra-row.accepted .req-state { color: var(--ok); }
.req-why-lead { font-size: .8125rem; color: var(--mute); }
/* Text written by the requester: quoted and set apart so it can't pass for JustID's own wording */
.req-why { margin: .25rem 0 .75rem; padding: .5rem 1rem; border-left: 3px solid var(--mute); background: var(--panel); font-style: italic; overflow-wrap: anywhere; }
.req-why::before { content: "«"; }
.req-why::after { content: "»"; }
.req-meta { font-size: .9375rem; }
.req-verify { font-size: .75rem; }
.chk { display: flex; gap: .625rem; align-items: flex-start; cursor: pointer; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  button.lock.wiggle svg { animation: none; }
  body.busy .top::after { animation: none; opacity: .6; }
  .switch i::before, .fld { transition: none; }
}

/* Privacy dialog: "learn more" (landing) and source code links */
.privacy-links { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; }
.privacy-links a { min-height: 44px; display: inline-flex; align-items: center; }

/* Specimen test mode: step 1's try links and the notice (ui/app/demo.js) */
.demo-try { margin: -.5rem 0 1.25rem; font-size: .9375rem; line-height: 1.5; }
.demo-try a { color: var(--cream); font-weight: 600; display: inline-block; padding-block: .625rem; margin-block: -.625rem; } /* 44px tap height without moving the text */
.demo-note { margin: 0 0 1rem; padding: .75rem 1rem; border-left: 4px solid var(--lime); background: var(--panel); color: var(--soft); line-height: 1.5; }
.demo-note a { color: var(--cream); font-weight: 600; white-space: nowrap; }
