/* Webster Build - public single-page UI. "Soft Depth" system (see docs/brandbook.md, section 11).
   Tokens copied from app/static/css/app.css so this service is self-contained.
   Fonts are self-hosted under /static/fonts (no external requests).
   Dark by default; light via prefers-color-scheme. Keep both light blocks identical. */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/inter-latin-wght.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/fraunces-latin-wght.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --bg: #1A1816; --surface: #221F1C; --elev: #2A2622; --hover: #342F2A;
  --border: rgba(255, 240, 225, 0.08); --border-mid: rgba(255, 240, 225, 0.16); --border-strong: #8A8178;
  --text: #F4EFE9; --text-2: #D8D0C7; --muted: #A59C92;
  --accent: #E87C2E; --accent-fg: #1A1208; --focus: #F08A3C;
  --ok: #6FD08C; --ok-bg: rgba(111, 208, 140, 0.14);
  --bad: #FF8F85; --bad-bg: rgba(255, 143, 133, 0.15);
  --warn: #E5C14F; --warn-bg: rgba(229, 193, 79, 0.14);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.30), 0 6px 18px rgba(0, 0, 0, 0.22);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.35), 0 18px 44px rgba(0, 0, 0, 0.50);
  --inner-hl: inset 0 1px 0 rgba(255, 240, 225, 0.05);
  --glow: 0 4px 16px rgba(232, 124, 46, 0.28);
  --topbar-bg: rgba(34, 31, 28, 0.80);
  --halo: rgba(232, 124, 46, 0.10);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --r-sm: 8px; --r-md: 14px; --r-lg: 18px; --r-pill: 999px;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #FAF8F5; --surface: #FFFFFF; --elev: #F6F3EE; --hover: #EFEBE4;
    --border: rgba(60, 40, 20, 0.10); --border-mid: rgba(60, 40, 20, 0.18); --border-strong: #8C8379;
    --text: #1C1814; --text-2: #3A332C; --muted: #6A6159;
    --focus: #B34E00;
    --ok: #136A2C; --ok-bg: rgba(19, 106, 44, 0.10);
    --bad: #B0221A; --bad-bg: rgba(176, 34, 26, 0.09);
    --warn: #7A5700; --warn-bg: rgba(160, 112, 0, 0.13);
    --shadow-1: 0 1px 2px rgba(60, 40, 20, 0.06), 0 4px 14px rgba(60, 40, 20, 0.05);
    --shadow-2: 0 2px 4px rgba(60, 40, 20, 0.06), 0 14px 36px rgba(60, 40, 20, 0.14);
    --inner-hl: inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --glow: 0 4px 14px rgba(232, 124, 46, 0.30);
    --topbar-bg: rgba(255, 255, 255, 0.82);
    --halo: rgba(232, 124, 46, 0.12);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 400 16px/1.55 var(--font); font-feature-settings: "cv11", "ss03";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background-image: radial-gradient(ellipse 70% 38% at 50% 0, var(--halo), transparent 70%);
  background-repeat: no-repeat;
}
h1, h2 { margin: 0; line-height: 1.15; }
p { margin: 0; }
a { color: var(--text); text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
.muted { color: var(--muted); }
.center { text-align: center; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(232, 124, 46, 0.35); }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 300; background: var(--accent); color: var(--accent-fg); padding: 8px 12px; border-radius: var(--r-sm); font-weight: 600; }
.skip-link:focus { top: 8px; }
#main:focus { outline: none; }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: baseline; gap: 12px; padding: 18px 24px;
}
.brand { font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; font-size: 14px; text-decoration: none; }
.brand-sub { font-weight: 500; color: var(--muted); letter-spacing: 0.16em; }
.by { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 24px 20px 40px; flex: 1; }
.hero { text-align: center; margin-bottom: 28px; }
h1 {
  font-family: var(--font-display); font-weight: 500; font-size: clamp(30px, 7.5vw, 42px);
  letter-spacing: -0.02em; line-height: 1.1; font-variation-settings: "opsz" 96; text-wrap: balance;
}
.lead { margin-top: 14px; color: var(--text-2); font-size: 17px; text-wrap: balance; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 28px; box-shadow: var(--inner-hl), var(--shadow-2);
}
.foot { margin-top: 22px; text-align: center; color: var(--muted); font-size: 13px; }
.foot a { color: var(--text-2); }

/* ---------- Form ---------- */
#build-form { display: grid; gap: 20px; }
.field { display: grid; gap: 6px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
label { font-size: 14px; font-weight: 500; color: var(--text); }
.opt { color: var(--muted); font-weight: 400; }
.count { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.count.near { color: var(--warn); }
.hint { color: var(--muted); font-size: 12.5px; }
.err { color: var(--bad); font-size: 13px; font-weight: 500; }
input, textarea {
  font: 400 16px/1.35 var(--font); color: var(--text); background: var(--elev);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  width: 100%; height: 46px; padding: 0 13px; min-width: 0;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
textarea { height: auto; padding: 11px 13px; resize: vertical; min-height: 110px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: var(--r-sm); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.form-err {
  color: var(--bad); background: var(--bad-bg); border-radius: var(--r-sm); padding: 11px 13px;
  font-size: 14px; font-weight: 500;
}
.fine { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: -6px; }

/* honeypot: off-screen, not display:none (bots still see it), unreachable by keyboard/AT */
.hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px;
  border: 1px solid var(--border-mid); border-radius: var(--r-sm); background: var(--surface); color: var(--text);
  font: 500 14px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--inner-hl), 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: background 150ms ease, border-color 150ms ease, filter 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.lg { height: 52px; font-size: 16px; padding: 0 28px; width: 100%; border-radius: 10px; }
.btn.primary {
  background: linear-gradient(180deg, #F08A3C, #E27526); border-color: #D9691B; color: var(--accent-fg); font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), var(--glow);
}
.btn.primary:hover { filter: brightness(1.06); background: linear-gradient(180deg, #F08A3C, #E27526); border-color: #D9691B; }
.btn.secondary { width: 100%; height: 46px; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.spin { width: 16px; height: 16px; border: 2px solid rgba(26, 18, 8, 0.3); border-top-color: var(--accent-fg); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Views ---------- */
.view-title { font-family: var(--font-display); font-weight: 500; font-size: 26px; letter-spacing: -0.015em; text-align: center; font-variation-settings: "opsz" 72; }
.view-title:focus { outline: none; }
#view-progress, #view-done, #view-failed { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; justify-items: stretch; }
#view-done, #view-failed { text-align: center; }
.stage-label { text-align: center; color: var(--muted); font-size: 13px; font-weight: 500; margin-top: -8px; }

/* ---------- Progress ---------- */
.status-msg { text-align: center; color: var(--text-2); min-height: 1.55em; }
.conn { text-align: center; color: var(--warn); background: var(--warn-bg); border-radius: var(--r-sm); padding: 8px 12px; font-size: 13px; }
.elapsed { text-align: center; font-size: 14px; }
.mono-num { font-variant-numeric: tabular-nums; font-weight: 600; margin-left: 6px; }
.expect { text-align: center; color: var(--muted); font-size: 13.5px; border-top: 1px solid var(--border); padding-top: 16px; }

.steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; }
.steps li { position: relative; display: flex; align-items: center; gap: 14px; padding: 9px 12px; border-radius: var(--r-sm); color: var(--muted); transition: background-color 200ms ease, color 200ms ease; }
.steps li::before { content: ""; position: absolute; left: 23px; top: -8px; height: 12px; width: 2px; background: var(--border-mid); }
.steps li:first-child::before { display: none; }
.step-name { font-weight: 500; }
.mark { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; display: grid; place-items: center; background: var(--surface); position: relative; z-index: 1; }
.steps li.done { color: var(--text-2); }
.steps li.done .mark { border-color: var(--ok); background: var(--ok-bg); }
.steps li.done .mark::after { content: ""; width: 6px; height: 11px; border: solid var(--ok); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.steps li.done::before, .steps li.current::before { background: var(--ok); }
.steps li.current { color: var(--text); background: var(--elev); }
.steps li.current .step-name { font-weight: 600; }
.steps li.current .mark { border-color: var(--accent); }
.steps li.current .mark::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(.8); opacity: .75; } 50% { transform: scale(1.15); opacity: 1; } }

/* wireframe page assembling itself */
.stage-art { display: grid; place-items: center; }
.wf {
  position: relative; width: 100%; max-width: 330px; aspect-ratio: 16 / 11; overflow: hidden;
  display: grid; grid-template-rows: 14% 32% 1fr 14%; gap: 6px; padding: 10px;
  background: var(--elev); border: 1px solid var(--border-mid); border-radius: var(--r-md); box-shadow: var(--inner-hl), var(--shadow-1);
}
.wf i, .wf .wf-img { display: block; background: color-mix(in srgb, var(--text) 16%, var(--elev)); border-radius: 4px; }
.wf-nav { display: flex; align-items: center; gap: 8px; }
.wf-logo { width: 18%; height: 60%; background: var(--accent) !important; opacity: .85; }
.wf-link { width: 12%; height: 30%; margin-left: auto; }
.wf-link + .wf-link { margin-left: 0; }
.wf-hero { display: grid; align-content: center; gap: 6px; }
.wf-h1 { width: 70%; height: 14px; } .wf-h2 { width: 48%; height: 8px; } .wf-cta { width: 22%; height: 14px; background: var(--border-strong) !important; }
.wf-img { min-height: 0; }
.wf-foot { display: flex; gap: 8px; align-items: center; } .wf-foot i { height: 8px; width: 24%; }
.wf-nav, .wf-hero > *, .wf-foot > * , .wf-img { animation: assemble 6s ease-in-out infinite both; }
.wf-hero > :nth-child(1) { animation-delay: .5s; } .wf-hero > :nth-child(2) { animation-delay: .9s; } .wf-hero > :nth-child(3) { animation-delay: 1.3s; }
.wf-img { animation-delay: 1.7s; } .wf-foot > :nth-child(1) { animation-delay: 2.3s; } .wf-foot > :nth-child(2) { animation-delay: 2.6s; }
.wf-nav { animation-delay: 0s; }
@keyframes assemble {
  0%, 2% { opacity: 0; transform: translateY(8px) scale(.97); }
  18%, 82% { opacity: 1; transform: none; }
  97%, 100% { opacity: 0; transform: translateY(-4px); }
}
.wf-scan {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 35%, color-mix(in srgb, var(--accent) 22%, transparent) 50%, transparent 65%);
  background-size: 250% 100%; animation: scan 3.2s ease-in-out infinite;
}
@keyframes scan { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.wf.is-waiting .wf-scan { opacity: .5; animation-duration: 6s; }
.wf.is-waiting * { animation-duration: 10s; }

/* reduced motion: static dot only */
.static-dot { display: none; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; background: var(--elev); border: 1px solid var(--border-mid); }
.static-dot .dot { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent); }

/* ---------- Done / failed ---------- */
.done-badge, .fail-badge { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; }
.done-badge { background: var(--ok-bg); color: var(--ok); }
.fail-badge { background: var(--bad-bg); color: var(--bad); }
#open-link { margin-top: 6px; }
.url-row { display: flex; gap: 10px; align-items: center; background: var(--elev); border: 1px solid var(--border-mid); border-radius: var(--r-sm); padding: 6px 6px 6px 12px; }
.url-text { flex: 1; min-width: 0; text-align: left; font: 400 13px/1.4 var(--mono); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url-row .btn { height: 34px; padding: 0 14px; }
.expiry { color: var(--muted); font-size: 13.5px; }
.fail-msg { color: var(--text-2); overflow-wrap: anywhere; }

@media (max-width: 480px) {
  .card { padding: 22px 18px; }
  .wrap { padding: 12px 14px 32px; }
  .top { padding: 16px 18px; }
  .lead { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .wf { display: none; }
  .static-dot { display: flex; }
}
