/* ==========================================================================
   Houselab Forms — Shared Modal System
   One modal shell, dynamic content per form type. Follows the locked brand
   tokens from houselab-brand-style-guide.html exactly — do not introduce new
   colors, radii, or fonts here.
   ========================================================================== */

:root {
  --bg: #F4F1EC;
  --bg-raised: #EBE8E2;
  --bg-card: #FFFFFF;
  --bg-hover: #E5E1DB;
  --bg-dark: #1A1917;
  --text: #1A1917;
  --text-dim: #5C5750;
  --text-muted: #9A9590;
  --accent: #E8512D;
  --accent-glow: rgba(232, 81, 45, 0.12);
  --green: #2D7A4F;
  --border: rgba(26, 25, 23, 0.1);
  --border-strong: rgba(26, 25, 23, 0.18);
  --mono: 'Space Mono', 'Courier New', monospace;
  --sans: 'Outfit', -apple-system, sans-serif;
  --serif: 'Instrument Serif', Georgia, serif;
}

/* ---------- overlay + shell ---------- */

.hl-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 25, 23, 0.72);
  z-index: 9000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}
.hl-modal-overlay.is-open { display: flex; }

.hl-modal {
  background: var(--bg);
  width: 100%;
  max-width: 640px;
  position: relative;
  margin: auto;
  border: 1px solid var(--border-strong);
  animation: hlModalIn 0.32s ease;
}
@keyframes hlModalIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .hl-modal { animation: none; }
}

.hl-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  z-index: 2;
}
.hl-modal-close:hover { border-color: var(--text); color: var(--text); }
.hl-modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hl-modal-close svg { width: 14px; height: 14px; }

/* ---------- header ---------- */

.hl-modal-header {
  padding: 44px 44px 28px;
  border-bottom: 1px solid var(--border);
}
.hl-modal-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.hl-modal-title {
  font-family: var(--serif);
  font-size: clamp(26px, 3.4vw, 34px);
  font-weight: 400;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 14px;
  padding-right: 32px;
}
.hl-modal-intro {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.75;
  color: var(--text-dim);
  max-width: 520px;
}

/* ---------- body / fields ---------- */

.hl-modal-body { padding: 32px 44px 8px; }

.hl-fieldgroup-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 30px 0 16px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}
.hl-fieldgroup-label:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.hl-field { margin-bottom: 20px; }
.hl-field.is-hidden { display: none; }

.hl-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 9px;
}
.hl-label .hl-optional {
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.hl-input,
.hl-select,
.hl-textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 300;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  padding: 13px 14px;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.2s ease;
}
.hl-input::placeholder,
.hl-textarea::placeholder { color: var(--text-muted); }
.hl-input:focus,
.hl-select:focus,
.hl-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.hl-textarea { resize: vertical; min-height: 84px; line-height: 1.6; }

.hl-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><polyline points='1,1 6,7 11,1' fill='none' stroke='%235C5750' stroke-width='1.4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* pill choice — used for single AND multi select */
.hl-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.hl-pill {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.hl-pill:hover { border-color: var(--text-dim); }
.hl-pill.is-selected {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.hl-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hl-pill-hint {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 8px;
}

.hl-error {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  margin-top: 6px;
  display: none;
}
.hl-field.has-error .hl-input,
.hl-field.has-error .hl-select,
.hl-field.has-error .hl-textarea { border-color: var(--accent); }
.hl-field.has-error .hl-error { display: block; }

/* ---------- footer ---------- */

.hl-modal-footer {
  padding: 28px 44px 40px;
}
.hl-submit-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.hl-btn-submit {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 0;
  padding: 15px 30px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.hl-btn-submit:hover { background: #FF6B47; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(232,81,45,0.25); }
.hl-btn-submit:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.hl-btn-submit svg { width: 13px; height: 11px; }

.hl-trust {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.6;
}

.hl-submit-error {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--accent);
  margin-top: 14px;
  display: none;
}

/* ---------- success state ---------- */

.hl-success {
  display: none;
  padding: 64px 44px 56px;
  text-align: center;
}
.hl-success.is-visible { display: block; }
.hl-success-mark {
  width: 52px; height: 52px;
  border: 1px solid var(--green);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 26px;
}
.hl-success-mark svg { width: 20px; height: 20px; }
.hl-success-title {
  font-family: var(--serif);
  font-size: 28px;
  color: var(--text);
  margin-bottom: 12px;
}
.hl-success-body {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1.75;
  max-width: 400px;
  margin: 0 auto;
}

/* ---------- loading state on the submit button ---------- */
.hl-spinner {
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: hlSpin 0.7s linear infinite;
  display: none;
}
.is-submitting .hl-spinner { display: inline-block; }
.is-submitting .hl-submit-label { display: none; }
@keyframes hlSpin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */

@media (max-width: 560px) {
  .hl-modal-overlay { padding: 0; align-items: stretch; }
  .hl-modal { max-width: none; min-height: 100%; border: none; }
  .hl-modal-header { padding: 56px 24px 24px; }
  .hl-modal-body { padding: 24px 24px 8px; }
  .hl-modal-footer { padding: 24px 24px 40px; }
  .hl-modal-close { top: 16px; right: 16px; }
  .hl-success { padding: 64px 24px 48px; }
}

/* body lock when modal open */
body.hl-modal-locked { overflow: hidden; }
