/* Page shell and the step-by-step flow of the Egyptian ID reader (see wizard.js and index.html).
   Mobile first: the base rules are for a phone in portrait; wider screens add columns. */
:root {
  --accent-weak:#e8f0fe; --shadow:0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06); --radius:14px; --tap:52px;
  --ok-weak:#e6f4ea; --warn:#8a5a00; --warn-weak:#fff3d1;
}
@media (prefers-color-scheme: dark) { :root { --accent-weak:#16253d; --shadow:none; --ok-weak:#12301b; --warn:#e8b93a; --warn-weak:#3a2f0b; } }
html { -webkit-text-size-adjust:100%; }
body { min-height:100vh; min-height:100dvh; padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); display:flex; flex-direction:column; }
main { width:100%; max-width:1080px; padding:clamp(12px, 3.5vw, 28px); flex:1; }
:focus-visible { outline:3px solid var(--accent); outline-offset:2px; }
.vh { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
button, .btn { touch-action:manipulation; }
button.big, label.btn.big { min-height:var(--tap); font-size:1.05rem; font-weight:600; width:100%; display:flex; align-items:center; justify-content:center; gap:10px; text-align:center; border-radius:12px; }
label.btn { border:1px solid var(--line); background:var(--card); color:var(--fg); cursor:pointer; padding:10px 14px; }
label.btn:focus-within { outline:3px solid var(--accent); outline-offset:2px; }
button.link { background:none; border:none; padding:8px 4px; color:var(--accent); text-decoration:underline; text-underline-offset:3px; }
button.primary:hover:not(:disabled) { filter:brightness(1.08); }
button svg, label.btn svg { flex:none; }

/* header */
.top { display:flex; align-items:center; gap:12px; margin:2px 0 14px; }
.logo { flex:none; width:44px; height:44px; border-radius:12px; background:var(--accent); color:#fff; display:flex; align-items:center; justify-content:center; }
.top h1 { font-size:clamp(1.15rem, 4.2vw, 1.6rem); line-height:1.2; margin:0; display:flex; flex-wrap:wrap; gap:2px 12px; align-items:baseline; }
.top h1 .ar { font-size:.85em; font-weight:600; color:var(--muted); }
.top p.sub { margin:2px 0 0; font-size:.9rem; }

/* progress bar */
.stepper { display:flex; list-style:none; margin:0 auto 14px; padding:0; max-width:760px; }
.stepper li { flex:1 1 0; position:relative; min-width:0; }
.stepper li + li::before { content:""; position:absolute; top:19px; inset-inline-end:50%; width:100%; height:3px; background:var(--line); z-index:0; }
.stepper li.done + li::before, .stepper li.skipped + li::before, .stepper li.current::before { background:var(--ok); }
.stepper li.current::before { background:linear-gradient(to right, var(--ok), var(--accent)); }
.stepper li.skipped + li::before { background:repeating-linear-gradient(to right, var(--ok) 0 6px, transparent 6px 10px); }
.stepper button { position:relative; z-index:1; width:100%; display:flex; flex-direction:column; align-items:center; gap:6px; background:none; border:none; padding:0 2px 4px; color:var(--muted); font-size:.78rem; line-height:1.2; min-height:44px; }
.stepper button:disabled { opacity:1; cursor:default; }
.stepper .dot { width:38px; height:38px; border-radius:50%; border:3px solid var(--line); background:var(--card); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:1rem; color:var(--muted); transition:background .2s, border-color .2s, transform .2s; }
.stepper .lbl { display:flex; flex-direction:column; align-items:center; }
.stepper .lbl .ar { font-size:.95em; font-weight:600; }
.stepper li.current .dot { background:var(--accent); border-color:var(--accent); color:#fff; transform:scale(1.08); box-shadow:0 0 0 5px var(--accent-weak); }
.stepper li.current button { color:var(--fg); font-weight:700; }
.stepper li.done .dot { background:var(--ok); border-color:var(--ok); color:#fff; }
.stepper li.done button { color:var(--fg); }
.stepper li.skipped .dot { border-style:dashed; }
.stepper li.todo.canjump button { color:var(--fg); }
.stepper li.done button:hover .dot, .stepper li.skipped button:hover .dot, .stepper li.canjump button:hover .dot { border-color:var(--accent); }
@media (min-width:640px) { .stepper button { font-size:.95rem; } .stepper .dot { width:42px; height:42px; } .stepper li + li::before { top:21px; } }

/* the card holding the steps */
.wiz { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); padding:clamp(14px, 3vw, 26px); }
.stephead { margin-bottom:14px; }
.stephead .kicker { margin:0; color:var(--accent); font-weight:700; font-size:.82rem; letter-spacing:.04em; text-transform:uppercase; }
.stephead h2 { margin:2px 0 4px; font-size:clamp(1.25rem, 5vw, 1.7rem); line-height:1.2; display:flex; flex-wrap:wrap; gap:2px 12px; align-items:baseline; }
.stephead h2 .ar { font-size:.8em; font-weight:600; color:var(--muted); }
.stephead h2:focus { outline:none; }
.stephead .lead { margin:0; color:var(--muted); }
.step { animation:stepin .25s ease-out; }
@keyframes stepin { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
@media (prefers-reduced-motion: reduce) { .step { animation:none; } .stepper .dot { transition:none; } .spin { animation-duration:3s !important; } }

.stepbody { display:grid; gap:18px; grid-template-columns:minmax(0,1fr); align-items:start; }
@media (min-width:820px) { .stepbody { grid-template-columns:minmax(0,5fr) minmax(0,6fr); gap:28px; } }
@media (max-height:520px) and (orientation:landscape) { .stepbody { grid-template-columns:minmax(0,1fr) minmax(0,1fr); } .art .tips { display:none; } }

/* the card drawing and tips */
.art { margin:0; }
.art .frame { position:relative; border-radius:12px; overflow:hidden; background:var(--panel2); border:1px solid var(--line); aspect-ratio:960/605; }
.art img { display:block; width:100%; height:100%; object-fit:cover; }
.art .badge { position:absolute; top:8px; inset-inline-start:8px; background:rgba(0,0,0,.65); color:#fff; border-radius:999px; padding:2px 10px; font-size:.78rem; font-weight:600; }
.art figcaption { margin-top:6px; font-size:.82rem; color:var(--muted); }
.tips { list-style:none; margin:10px 0 0; padding:0; display:grid; gap:6px; }
.tips li { display:flex; gap:10px; align-items:center; font-size:.9rem; }
.tips .ti { flex:none; width:28px; height:28px; border-radius:8px; background:var(--accent-weak); color:var(--accent); display:flex; align-items:center; justify-content:center; }
@media (max-width:819px) { .art { display:grid; grid-template-columns:minmax(0,1fr); } .art.compact .tips { display:none; } }
@media (max-width:819px) and (min-width:480px) { .tips { grid-template-columns:1fr 1fr; } }

/* actions column */
.acts { display:grid; gap:10px; min-width:0; }
.acts .or { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:.82rem; }
.acts .or::before, .acts .or::after { content:""; flex:1; height:1px; background:var(--line); }
.acts .hint { margin:0; font-size:.85rem; color:var(--muted); }
details.typed { border:1px solid var(--line); border-radius:12px; padding:0 12px; }
details.typed summary { cursor:pointer; padding:12px 0; min-height:44px; font-weight:600; }
details.typed .inner { display:grid; gap:8px; padding:0 0 12px; }
details.typed input[type=text] { width:100%; padding:12px; min-height:var(--tap); border:1px solid var(--line); border-radius:10px; background:transparent; color:var(--fg); font:inherit; font-size:1.1rem; letter-spacing:.06em; }
.prevok { display:flex; gap:8px; align-items:center; padding:8px 12px; border-radius:10px; background:var(--ok-weak); color:var(--ok); font-weight:600; font-size:.9rem; margin-bottom:12px; }

/* camera */
.cam { display:grid; gap:8px; }
.cam .vwrap { position:relative; border-radius:12px; overflow:hidden; background:#000; }
.cam video { display:block; width:100%; max-height:62vh; max-height:62dvh; object-fit:contain; border-radius:0; }
.cam .hintbar { padding:10px 12px; border-radius:10px; background:#222; color:#fff; text-align:center; font-weight:600; }
.cam .camrow { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.cam label.chk { grid-column:1 / -1; font-size:.88rem; }

/* status and busy */
#status { margin:0 0 12px; min-height:0; padding:0; border-radius:10px; }
#status:not(:empty) { padding:10px 12px; background:var(--panel2); }
#status.ok { background:var(--ok-weak); } #status.bad { background:var(--g-problem-bg); color:var(--g-problem); }
.busy { display:flex; align-items:center; gap:12px; padding:14px; border-radius:12px; background:var(--accent-weak); }
.busy .t { display:grid; }
.busy .t small { color:var(--muted); }
.spin { width:26px; height:26px; border-radius:50%; border:4px solid var(--line); border-top-color:var(--accent); animation:spin .9s linear infinite; flex:none; }
@keyframes spin { to { transform:rotate(360deg); } }
.bar { height:4px; border-radius:2px; background:var(--line); overflow:hidden; margin-top:6px; }
.bar i { display:block; height:100%; width:40%; background:var(--accent); border-radius:2px; animation:slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { margin-inline-start:-40%; } 100% { margin-inline-start:100%; } }
@media (prefers-reduced-motion: reduce) { .bar i { animation:none; width:100%; } }

/* a face already read */
.facedone { display:grid; gap:12px; padding:16px; border-radius:12px; border:1px solid var(--line); background:var(--ok-weak); }
.facedone.warn { background:var(--warn-weak); }
.facedone .hd { display:flex; gap:12px; align-items:flex-start; }
.facedone .ic { flex:none; width:36px; height:36px; border-radius:50%; background:var(--ok); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:700; }
.facedone.warn .ic { background:var(--warn); color:var(--card); }
.facedone h3 { margin:0; font-size:1.05rem; } .facedone p { margin:2px 0 0; color:var(--muted); font-size:.9rem; }
.facedone .btns { display:grid; gap:8px; }

/* result step */
.resultbar { display:grid; gap:8px; margin:0 0 14px; grid-template-columns:minmax(0,1fr); }
@media (min-width:560px) { .resultbar { grid-template-columns:repeat(3, minmax(0,1fr)); } }
.resultbar button { min-height:46px; }
#out { border:none; padding:0; background:none; margin:0; }

/* buttons side by side where there is room */
@media (min-width:560px) { .facedone .btns { grid-template-columns:1fr 1fr; } }

footer.foot { padding:6px clamp(12px, 3.5vw, 28px) 18px; text-align:center; color:var(--muted); font-size:.8rem; max-width:1080px; margin:0 auto; width:100%; }

/* print: the result only */
@media print {
  .top, .stepper, #stepFace, .resultbar, #status, footer.foot, .stephead .lead, .stephead .kicker { display:none !important; }
  .wiz { border:none; box-shadow:none; padding:0; } .step { animation:none; }
  .stephead h2 { font-size:1.2rem; }
}
