/* ============================================================
 * CTP-Intake v1.2 — Global stylesheet
 * Consumes only theme tokens from theme-*.css. No hardcoded
 * colors. Boutique-PE design language: warm cream + ink + brass
 * (or navy + gold for tenant overrides). No gradients, no drop
 * shadows on solid blocks.
 * ============================================================ */

/* ---------- Reset + base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-soft);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 32px 120px;  /* bottom padding leaves room for sticky submit footer */
}

/* ---------- Type system ---------- */
.display-1 {
  font-family: 'Newsreader', 'Iowan Old Style', 'Charter', Georgia, serif;
  font-weight: 500;
  font-size: 48px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0;
}
.display-2 {
  font-family: 'Newsreader', 'Iowan Old Style', 'Charter', Georgia, serif;
  font-weight: 500;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
}
h1 {
  font-family: 'Newsreader', 'Iowan Old Style', 'Charter', Georgia, serif;
  font-weight: 500;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0;
}
h2, .section-title {
  font-family: 'Newsreader', 'Iowan Old Style', 'Charter', Georgia, serif;
  font-weight: 500;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}
h3 {
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 500;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--ink);
  margin: 0;
}
.body { font-size: 16px; line-height: 1.55; }
.small { font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.micro-label {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
code, .mono {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 32px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.header-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  color: var(--ink);
}
.header-wordmark {
  font-family: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.tenant-shield {
  display: inline-flex;
  align-items: center;
  height: 120px;
  color: var(--accent);
}
.tenant-shield svg,
.tenant-shield img { height: 100%; width: auto; display: block; }
.tenant-wordmark {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.05;
}
.wordmark-primary {
  font-family: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.wordmark-secondary {
  font-family: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  font-weight: 400;
  font-size: 16px;        /* ~60% of primary 28px, rounded for tabular feel */
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  margin-top: 2px;
}
.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}
.header-meta .micro-label { color: var(--ink-mute); }
.meta-tenant {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 18px;
  color: var(--ink);
}
.meta-email {
  font-size: 14px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 32px 32px 48px;
  text-align: center;
  color: var(--ink-mute);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-top: 1px solid var(--line);
  margin-top: 64px;
}
.site-footer small { font-size: 12px; }

/* ---------- Stage transitions ---------- */
.stage { animation: fadeIn .25s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Form base ---------- */
input, button, select, textarea, legend {
  font: inherit;
  color: inherit;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"] {
  display: block;
  width: 100%;
  height: 48px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input:disabled {
  background: var(--surface-alt);
  color: var(--ink-mute);
  cursor: not-allowed;
}
input[aria-invalid="true"] { border-color: var(--error); }
input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(139, 58, 43, 0.20);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field-label {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.req {
  color: var(--accent);
  font-weight: 600;
  margin-left: 2px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s;
  user-select: none;
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 1;
}
.btn-block { width: 100%; }
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.btn-primary:disabled {
  background: var(--line);
  border-color: var(--line);
  color: var(--ink-mute);
}
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--ink);
}
.btn.is-loading {
  color: transparent;
  position: relative;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 50% 0 0 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid color-mix(in srgb, var(--bg) 40%, transparent);
  border-top-color: var(--bg);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth card (S1) ---------- */
.auth-card {
  width: 100%;
  max-width: 440px;
  margin: 80px auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 48px;
  box-shadow: 0 1px 2px rgba(26, 22, 18, 0.04);
}
.auth-card .display-2 {
  margin-bottom: 8px;
}
.auth-sub {
  margin: 0 0 32px;
}
#auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
#auth-form .field input {
  height: 56px;
  font-size: 16px;
}
#auth-form .btn {
  margin-top: 4px;
}
.msg-error {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--error);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ---------- Engagement card (S3) ---------- */
.card-engagement {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  margin: 0 0 32px;
}
.section-label {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-bottom: 24px;
  padding: 0;
}
.section-label .micro-label { white-space: nowrap; }
.hairline {
  flex: 1;
  height: 1px;
  background: var(--line);
}
.field-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

/* ---------- Upload intro (S4) ---------- */
.upload-intro {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 24px;
  margin: 0 0 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-intro-body {
  margin: 0;
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.upload-intro-meta {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  color: var(--ink-mute);
  letter-spacing: 0.02em;
}

/* ---------- Size tracker (v1.2a static; v1.2b will add scroll-aware sticky + progress fill) ---------- */
.size-tracker {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 24px;
  margin: 0 0 32px;
}
.size-tracker-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.size-tracker-figure {
  font-family: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.size-tracker-of {
  font-size: 14px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
.size-tracker-right {
  font-size: 14px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}

/* ---------- Section + section header (S6) ---------- */
.section {
  margin-top: 32px;
  margin-bottom: 24px;
}
.section:last-of-type { margin-bottom: 0; }
.section-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 24px;
}
.section-num { white-space: nowrap; }
.section-title { white-space: nowrap; }

/* ---------- Slot grid + slot card (S7) ---------- */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.slot {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color .15s;
}
.slot.state-filled { border-color: var(--line-strong); }
.slot-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.slot-meta {
  white-space: nowrap;
}
.slot-required-badge {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

/* drop zone */
.slot-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 96px;
  padding: 16px;
  background: var(--surface-alt);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.slot-drop:hover {
  border-color: var(--accent);
  background: var(--accent-tint-5);
}
.slot-drop input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.slot-drop-icon {
  display: inline-flex;
  color: var(--ink-mute);
}
.slot-drop-text {
  font-size: 14px;
  color: var(--ink-soft);
}
.slot-drop-hint {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

/* filled state */
.slot.state-filled .slot-drop-empty { display: none; }
.slot.state-empty .slot-drop-filled { display: none; }
.slot:not(.state-filled) .slot-remove { display: none; }
.slot.state-filled .slot-drop {
  background: var(--surface);
  border-style: solid;
  border-color: var(--line-strong);
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: auto;
}
.slot-drop-filled {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.slot-filename {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.slot-size {
  font-size: 12px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.slot-remove {
  background: none;
  border: none;
  padding: 4px 0;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
}
.slot-remove:hover { text-decoration: underline; }

/* error state */
.slot.state-error .slot-drop {
  border-color: var(--error);
  border-style: solid;
  background: color-mix(in srgb, var(--error) 6%, var(--surface-alt));
}
.slot.state-error .slot-drop-text { color: var(--error); font-weight: 500; }
.slot.state-error .slot-drop-icon { color: var(--error); }

/* paired name field */
.slot-name-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slot-name-input {
  height: 40px !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
}
.slot-name-input[aria-invalid="true"] {
  border-color: var(--error);
  background: color-mix(in srgb, var(--error) 4%, var(--surface));
}
.slot-name-error {
  font-size: 12px;
  color: var(--error);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* responsive */
@media (max-width: 768px) {
  .field-grid-2 { grid-template-columns: 1fr; }
  .slot-grid { grid-template-columns: 1fr; }
  .site-header { flex-direction: column; align-items: flex-start; }
  .header-meta { align-items: flex-start; text-align: left; }
}

/* ---------- Sticky submit footer (S8) ---------- */
.submit-row {
  position: sticky;
  bottom: 24px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 24px;
  margin: 32px 0 0;
  box-shadow: 0 1px 3px rgba(26, 22, 18, 0.05);
}
.submit-gate-msg {
  flex: 1;
  color: var(--ink-mute);
}
.submit-gate-msg.is-blocking {
  color: var(--error);
}
.submit-gate-msg.is-ready {
  color: var(--success);
}

/* ---------- Messages ---------- */
.msg {
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.msg-error.msg, .msg.msg-error {
  background: color-mix(in srgb, var(--error) 6%, var(--surface));
  border-color: var(--error);
  color: var(--error);
}
.msg-warn {
  background: color-mix(in srgb, #C99A1F 6%, var(--surface));
  border-color: #C99A1F;
  color: #6E5212;
}
.msg-info {
  background: var(--surface-alt);
  border-color: var(--line);
  color: var(--ink-soft);
}

/* ---------- Success card (S9) ---------- */
.success-card {
  width: 100%;
  max-width: 600px;
  margin: 64px auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 64px 48px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.success-check {
  display: inline-flex;
  color: var(--success);
}
.success-card .display-2 { margin: 0; }
.success-lede {
  margin: 0;
  color: var(--ink-soft);
  max-width: 420px;
}
.ref-display {
  position: relative;
  width: 100%;
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 16px 96px 16px 16px;
  display: flex;
  align-items: center;
  margin: 8px 0;
}
.ref-display code {
  font-size: 16px;
  color: var(--ink);
  font-weight: 500;
  word-break: break-all;
}
.ref-copy {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .15s;
}
.ref-copy:hover { background: var(--surface-alt); }
.ref-copy.is-copied {
  background: var(--success);
  border-color: var(--success);
  color: var(--bg);
}
.success-foot {
  margin: 0;
  font-size: 13px;
  color: var(--ink-mute);
}
.conf-details {
  width: 100%;
  margin-top: 24px;
  text-align: left;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.conf-details summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 0;
}
.conf-details summary::-webkit-details-marker { display: none; }
.conf-details summary::after {
  content: " ▸";
  color: var(--ink-mute);
}
.conf-details[open] summary::after { content: " ▾"; }
.receipt {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 24px;
  row-gap: 8px;
  margin: 16px 0 0;
  font-size: 14px;
}
.receipt dt { color: var(--ink-mute); font-weight: 500; }
.receipt dd { margin: 0; color: var(--ink-soft); }
.receipt code {
  font-size: 13px;
  background: var(--surface-alt);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---------- v1.2 R2: paired reason textarea (sections 2/3a/3b) ----- */
/* Appears below candidate-name on slots in sections 2/3a/3b only.
   Section 1 slots get no .slot-reason-field. Always optional —
   never gates submission, never shows an error state. */
.slot-reason-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.slot-reason-input {
  display: block;
  width: 100%;
  min-height: 76px;            /* approx 3 rows of 14px line at 1.45 */
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;            /* user can grow; fixed-min */
  transition: border-color .15s, box-shadow .15s;
}
.slot-reason-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
