/* ─────────────────────────────────────────────
   JR Agency — Referral Intake
   ───────────────────────────────────────────── */

:root {
  --navy:        #123a63;
  --navy-deep:   #0d2b4a;
  --navy-tint:   #eef3f9;
  --accent:      #c8102e;
  --ink:         #14181d;
  --ink-2:       #4a5461;
  --ink-3:       #737f8c;
  --line:        #dfe4ea;
  --line-strong: #c6cdd6;
  --bg:          #f4f6f9;
  --card:        #ffffff;
  --ok:          #1a7f4b;
  --err:         #c0281c;
  --err-bg:      #fdf2f1;
  --radius:      12px;
  --shadow:      0 1px 2px rgba(16,32,54,.06), 0 8px 24px -12px rgba(16,32,54,.18);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* A class rule that sets display (.grid, .success, .budget) otherwise beats the
   user-agent [hidden] rule, leaving "hidden" sections on screen. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 20px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.hp { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* ───────── Header ───────── */

.site-header {
  background: var(--navy);
  color: #fff;
  padding: env(safe-area-inset-top) 0 0;
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 66px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 9px;
  background: rgba(255,255,255,.13);
  border: 1px solid rgba(255,255,255,.2);
  font: 700 15px/1 Georgia, "Times New Roman", serif;
  letter-spacing: .5px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.brand-text small { font-size: 12px; color: rgba(255,255,255,.66); letter-spacing: .02em; }

.header-call {
  color: rgba(255,255,255,.85); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  padding: 8px 14px; border-radius: 100px;
  border: 1px solid rgba(255,255,255,.24);
  white-space: nowrap;
}
.header-call:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ───────── Intro ───────── */

.intro { padding: 40px 0 28px; }

.intro h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 5.4vw, 34px);
  line-height: 1.15;
  letter-spacing: -.022em;
  font-weight: 660;
  color: var(--navy-deep);
}

.intro p {
  margin: 0; max-width: 60ch;
  color: var(--ink-2); font-size: 15.5px;
}

/* ───────── Cards ───────── */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
}

.card-head { display: flex; gap: 14px; margin-bottom: 20px; }

.step {
  flex: none;
  display: grid; place-items: center;
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--navy-tint); color: var(--navy);
  font-size: 13px; font-weight: 700;
  margin-top: 1px;
}

.card-head h2 {
  margin: 0 0 2px;
  font-size: 17.5px; font-weight: 640; letter-spacing: -.012em;
  color: var(--navy-deep);
}

.card-head p { margin: 0; font-size: 13.75px; color: var(--ink-3); }

/* ───────── Fields ───────── */

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.span-2 { grid-column: 1 / -1; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split > div { min-width: 0; }

.field { min-width: 0; }

label {
  display: block;
  font-size: 13.25px; font-weight: 600; letter-spacing: .005em;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.req { color: var(--accent); font-weight: 700; }
.opt { color: var(--ink-3); font-weight: 400; font-size: .92em; }

input[type="text"], input[type="tel"], input[type="email"],
input[type="date"], select, textarea {
  width: 100%;
  font: inherit; font-size: 16px; /* 16px prevents iOS zoom-on-focus */
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 11px 13px;
  transition: border-color .12s, box-shadow .12s;
  -webkit-appearance: none; appearance: none;
}

textarea { resize: vertical; min-height: 92px; line-height: 1.5; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%234a5461' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 11px;
  padding-right: 34px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(18,58,99,.14);
}

input::placeholder, textarea::placeholder { color: #a8b1bb; }

.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-3); }

.err { margin: 0; font-size: 12.5px; color: var(--err); font-weight: 500; min-height: 0; }
.err:not(:empty) { margin-top: 6px; }

.invalid input, .invalid select, .invalid textarea,
input.invalid, select.invalid, textarea.invalid {
  border-color: var(--err);
  background: var(--err-bg);
}

/* ───────── VIN ───────── */

#vin { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .09em; text-transform: uppercase; }

.vin-meter {
  margin-top: 6px;
  font: 500 12px/1 ui-monospace, Menlo, Consolas, monospace;
  color: var(--ink-3);
  text-align: right;
}
.vin-meter.full { color: var(--ok); font-weight: 700; }

/* ───────── Radio choices ───────── */

.choice-set { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }

@media (min-width: 560px) {
  .choice-set { grid-template-columns: repeat(3, 1fr); }
}

.choice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  margin: 0;
  transition: border-color .12s, background .12s, box-shadow .12s;
}

.choice:hover { border-color: var(--navy); }

.choice input { flex: none; margin: 3px 0 0; accent-color: var(--navy); width: 17px; height: 17px; }

.choice-body { display: flex; flex-direction: column; min-width: 0; }
.choice-title { font-size: 14.5px; font-weight: 620; color: var(--ink); line-height: 1.3; }
.choice-sub  { font-size: 12.25px; color: var(--ink-3); line-height: 1.35; margin-top: 2px; }

.choice:has(input:checked) {
  border-color: var(--navy);
  background: var(--navy-tint);
  box-shadow: inset 0 0 0 1px var(--navy);
}

.choice:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(18,58,99,.16); }

.conditional { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line-strong); }

/* ───────── Dropzone ───────── */

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: 11px;
  background: #fbfcfd;
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

.dropzone:hover, .dropzone:focus-visible, .dropzone.over {
  border-color: var(--navy);
  background: var(--navy-tint);
  outline: none;
}

.dropzone svg { width: 26px; height: 26px; color: var(--navy); display: block; margin: 0 auto 8px; }
.dz-main { margin: 0; font-size: 14.75px; font-weight: 600; color: var(--ink); }
.dz-sub  { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-3); }

.filelist { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }

.filelist li {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 13.5px;
}

.fi-icon {
  flex: none; width: 30px; height: 30px; border-radius: 7px;
  background: var(--navy-tint); color: var(--navy);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800; letter-spacing: .02em;
  overflow: hidden;
}
.fi-icon img { width: 100%; height: 100%; object-fit: cover; }

.fi-meta { min-width: 0; flex: 1; }
.fi-name { display: block; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-sub  { display: block; font-size: 12px; color: var(--ink-3); }

.fi-uploading .fi-sub { color: var(--navy); }
.fi-error .fi-sub { color: var(--err); font-weight: 600; }

.fi-actions { flex: none; display: flex; align-items: center; gap: 2px; }

.fi-retry {
  flex: none; border: 1px solid var(--line-strong); background: #fff;
  color: var(--navy); font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 100px; cursor: pointer;
}
.fi-retry:hover { background: var(--navy-tint); }

.fi-remove {
  flex: none; border: 0; background: transparent; cursor: pointer;
  color: var(--ink-3); font-size: 20px; line-height: 1;
  padding: 4px 7px; border-radius: 6px;
}
.fi-remove:hover { background: var(--err-bg); color: var(--err); }

.filelist-summary { margin: 10px 0 0; font-size: 12.25px; color: var(--ink-3); }

/* ───────── Consent ───────── */

.consent {
  display: flex; align-items: flex-start; gap: 12px;
  margin: 18px 0 0; padding: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fbfcfd;
  font-weight: 400; font-size: 13.75px; line-height: 1.5;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

.consent strong { display: block; color: var(--ink); font-weight: 640; margin-bottom: 2px; }

.consent input {
  flex: none; margin: 2px 0 0;
  width: 19px; height: 19px;
  accent-color: var(--navy);
}

.consent:has(input:checked) { border-color: var(--ok); background: #f2f9f5; }
.consent.invalid { border-color: var(--err); background: var(--err-bg); }

/* ───────── Submit ───────── */

.submit-row { margin: 24px 0 8px; text-align: center; }

.btn {
  position: relative;
  width: 100%;
  font: inherit; font-size: 16px; font-weight: 640; letter-spacing: .005em;
  color: #fff; background: var(--navy);
  border: 0; border-radius: 10px;
  padding: 15px 26px;
  cursor: pointer;
  transition: background .12s, transform .06s;
  box-shadow: 0 2px 8px -2px rgba(18,58,99,.4);
}

.btn:hover { background: var(--navy-deep); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .62; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid rgba(18,58,99,.35); outline-offset: 2px; }

@media (min-width: 560px) { .btn { width: auto; min-width: 260px; } }

.btn-ghost {
  background: transparent; color: var(--navy);
  border: 1px solid var(--line-strong); box-shadow: none;
  font-size: 14.5px; padding: 12px 22px;
}
.btn-ghost:hover { background: var(--navy-tint); color: var(--navy-deep); }

.spinner {
  display: none;
  position: absolute; top: 50%; left: 50%;
  margin: -9px 0 0 -9px;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.btn.loading .btn-label { visibility: hidden; }
.btn.loading .spinner  { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

.submit-note { margin: 11px 0 0; font-size: 12.75px; color: var(--ink-3); }

.form-error {
  margin: 14px 0 0; padding: 13px 15px;
  border: 1px solid #f0c4c0; border-left: 3px solid var(--err);
  border-radius: 9px; background: var(--err-bg);
  color: #8f2018; font-size: 14px; font-weight: 500;
}

/* ───────── Success ───────── */

.success {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 26px;
  margin: 40px 0;
  text-align: center;
}

.check {
  width: 54px; height: 54px; margin: 0 auto 18px;
  border-radius: 50%;
  background: #e8f5ee; color: var(--ok);
  display: grid; place-items: center;
}
.check svg { width: 27px; height: 27px; }

.success h2 {
  margin: 0 0 7px;
  font-size: 23px; font-weight: 650; letter-spacing: -.018em;
  color: var(--navy-deep);
}

.success-sub { margin: 0 auto 24px; max-width: 44ch; color: var(--ink-2); font-size: 15px; }

.receipt {
  margin: 0 0 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  text-align: left;
}

.receipt > div {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--line);
}
.receipt > div:last-child { border-bottom: 0; }

.receipt dt { font-size: 12.75px; color: var(--ink-3); font-weight: 500; }
.receipt dd {
  margin: 0; font-size: 13.75px; font-weight: 620; color: var(--ink);
  text-align: right; word-break: break-word;
}
#ref-no { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .03em; }

/* ───────── Footer ───────── */

.site-footer {
  margin-top: 44px;
  padding: 26px 0 calc(30px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}

.site-footer p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.site-footer .fine { margin-top: 7px; font-size: 12px; color: var(--ink-3); max-width: 68ch; line-height: 1.5; }

/* ───────── Mobile ───────── */

@media (max-width: 560px) {
  .wrap { padding: 0 15px; }
  .intro { padding: 28px 0 20px; }
  .card { padding: 18px 16px; border-radius: 11px; }
  .grid { grid-template-columns: 1fr; gap: 15px; }
  .span-2 { grid-column: auto; }
  .header-call { display: none; }
  .success { padding: 32px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
