/* ============================================
   Home Direct Marketing - Affiliate Onboarding
   Light theme, warm orange accent, matches homedirectmarketing.com
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f7f8fa;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border-color: #d0d7de;
  --border-focus: #E16D48;
  --accent: #E16D48;
  --accent-hover: #D45A38;
  --accent-deep: #B64B2F;
  --accent-glow: rgba(225, 109, 72, 0.18);
  --accent-subtle: rgba(225, 109, 72, 0.06);
  --text-primary: #1f2328;
  --text-secondary: #57606a;
  --text-muted: #8c959f;
  --success: #1a7f37;
  --success-bg: rgba(26, 127, 55, 0.08);
  --error: #cf222e;
  --error-bg: rgba(207, 34, 46, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(31, 35, 40, 0.06), 0 4px 12px rgba(31, 35, 40, 0.06);
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(225, 109, 72, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(225, 109, 72, 0.04) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.page-wrapper { position: relative; z-index: 1; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---- Header ---- */
.header {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.logo a {
  display: inline-block;
}

.logo-img {
  height: 44px;
  width: auto;
  display: block;
}

@media (max-width: 600px) {
  .logo-img { height: 40px; }
}

.logo-text {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-accent { color: var(--accent); }

/* ---- Hero ---- */
.hero {
  padding: 3.5rem 0 2rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.hero h1 span {
  color: var(--accent);
}

.hero-attribution {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0.5rem 0 1.25rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.hero-attribution strong {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.hero-attribution-line {
  display: inline-block;
  width: 2.25rem;
  height: 1px;
  flex-shrink: 0;
  background: linear-gradient(90deg, transparent, var(--border-color) 50%, transparent);
}

@media (max-width: 600px) {
  .hero-attribution {
    font-size: 0.7rem;
    gap: 0.5rem;
    letter-spacing: 0.1em;
  }
  .hero-attribution strong { letter-spacing: 0.08em; }
  .hero-attribution-line { width: 1.25rem; }
}

@media (max-width: 380px) {
  .hero-attribution-line { display: none; }
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* ---- Content Grid ---- */
.main { padding-bottom: 3rem; }

.content-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2.5rem;
  align-items: start;
}

/* ---- Form Card ---- */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}

.form-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.form-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* Section divider labels */
.form-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 1.25rem;
  margin-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

/* ---- Form Fields ---- */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group > label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.required { color: var(--accent); margin-left: 2px; }
.hint { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="url"],
.form-group select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input::placeholder { color: var(--text-muted); }

.form-group input:focus,
.form-group select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b95a9' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
  cursor: pointer;
}

.form-group select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Error messages */
.error-message {
  display: none;
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 0.3rem;
}

.has-error .error-message { display: block; }

.has-error input,
.has-error select {
  border-color: var(--error) !important;
}

/* ---- Checkbox Groups ---- */
.checkbox-group > label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.checkbox-label:hover {
  border-color: rgba(225, 109, 72, 0.35);
  background: var(--accent-subtle);
}

.checkbox-label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all var(--transition);
}

.checkbox-label input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 4px;
  height: 8px;
  border: solid var(--bg-primary);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.has-error .checkbox-grid .checkbox-label {
  border-color: rgba(207, 34, 46, 0.5);
}

/* ---- Consent Disclaimer (above submit) ---- */
.form-consent {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

.form-consent a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: var(--border-color);
  text-underline-offset: 2px;
}

.form-consent a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* ---- Submit Button ---- */
.btn-submit {
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: var(--accent);
  color: #ffffff;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-submit:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-loading { display: none; align-items: center; gap: 0.5rem; }

.spinner {
  width: 20px;
  height: 20px;
  animation: spin 0.7s linear infinite;
}

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

/* ---- Success State ---- */
.success-state {
  text-align: center;
  padding: 2rem 1rem;
}

.success-icon {
  width: 72px;
  height: 72px;
  background: var(--success-bg);
  border: 2px solid var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2rem;
  color: var(--success);
  animation: scaleIn 0.4s ease both;
}

.success-state h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.success-state p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

/* ---- Error State ---- */
.error-state {
  background: var(--error-bg);
  border: 1px solid rgba(207, 34, 46, 0.35);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  color: var(--error);
  font-size: 0.875rem;
}

.error-request-id {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: rgba(207, 34, 46, 0.8);
  letter-spacing: 0.02em;
}

/* ---- Benefits Sidebar ---- */
.benefits-section {
  content-visibility: auto;
  contain-intrinsic-size: 1px 800px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 2rem;
}

.benefit-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color var(--transition), transform var(--transition);
}

.benefit-card:hover {
  border-color: rgba(225, 109, 72, 0.35);
  transform: translateY(-2px);
}

.benefit-icon {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.benefit-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.benefit-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-links {
  margin-bottom: 0.6rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-sep { color: var(--text-muted); }

/* ---- Legal Pages (privacy, terms) ---- */
.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  color: var(--text-primary);
  line-height: 1.65;
}

.legal-page .legal-intro {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.legal-page .legal-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.legal-page h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.legal-page h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 2.25rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.legal-page h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.legal-page p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.legal-page ul, .legal-page ol {
  margin: 0.5rem 0 1rem 1.5rem;
  color: var(--text-secondary);
}

.legal-page li {
  margin-bottom: 0.35rem;
}

.legal-page strong { color: var(--text-primary); font-weight: 600; }

.legal-page a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.legal-page .legal-note {
  background: var(--accent-subtle);
  border-left: 3px solid var(--accent);
  padding: 0.9rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  color: var(--text-primary);
  margin: 1.25rem 0;
}

.legal-page .legal-note strong { color: var(--accent-deep); }

.legal-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.88rem;
}

.legal-page th, .legal-page td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.legal-page th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.legal-page td { color: var(--text-secondary); }

.legal-back {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
}

.legal-back:hover { color: var(--accent); }

/* ---- Character Count ---- */
.field-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.3rem;
}

.field-meta .error-message {
  margin-top: 0;
}

.char-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  transition: color var(--transition);
}

.char-count.near-limit {
  color: #f59e0b;
}

.char-count.at-limit {
  color: var(--error);
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .benefits-section {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    order: -1;
  }

  .hero h1 { font-size: 1.85rem; }
  .hero-subtitle { font-size: 1rem; }
}

@media (max-width: 540px) {
  .container { padding: 0 1rem; }
  .form-card { padding: 1.75rem 1.25rem; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .checkbox-grid { grid-template-columns: 1fr; }

  .benefits-section {
    grid-template-columns: 1fr;
  }
}


/* ---- Fieldset Reset ---- */
.form-fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.form-fieldset > legend.form-section-label {
  width: 100%;
}

/* ---- Skip Link (Accessibility) ---- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  z-index: 1000;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 1rem;
  outline: 3px solid var(--accent-hover);
  outline-offset: 2px;
}

/* ---- Screen Reader Only ---- */
.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;
}

/* ---- Submit Button Shake Animation ---- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.btn-shake {
  animation: shake 0.5s ease;
}

/* ---- Retry Button ---- */
.btn-retry {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.55rem 1.25rem;
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-retry:hover {
  background: var(--error-bg);
  color: #fff;
}

.btn-retry:focus-visible {
  outline: 3px solid var(--error);
  outline-offset: 2px;
}

/* ---- Toast Notifications ---- */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: 380px;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-exit {
  opacity: 0;
  transform: translateX(100%);
}

.toast-info {
  background: #1e3a5f;
  color: #93c5fd;
  border: 1px solid #2563eb;
}

.toast-success {
  background: #14532d;
  color: #86efac;
  border: 1px solid #22c55e;
}

.toast-warning {
  background: #451a03;
  color: #fde68a;
  border: 1px solid #f59e0b;
}

.toast-error {
  background: #450a0a;
  color: #fca5a5;
  border: 1px solid #ef4444;
}

/* ---- Focus Visible (keyboard accessibility) ---- */
input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.checkbox-label:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---- CAPTCHA ---- */
.captcha-group #turnstile-container {
  margin-top: 0.4rem;
}

.captcha-group iframe {
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html { scroll-behavior: auto; }
}
