/* ==========================================================================
   MH Lending Services — Legal Pages Shared Stylesheet
   Covers: privacy-policy.html, terms-of-service.html, state-licensing.html
   WCAG 2.1 AA compliant · Mobile responsive · Print-friendly
   ========================================================================== */

/* ── CSS Variables ─────────────────────────────────────────────────────── */
:root {
  --navy:        #0F172A;
  --navy-mid:    #1E293B;
  --navy-light:  #334155;
  --gold:        #F59E0B;
  --gold-dark:   #D97706;
  --blue:        #1D4ED8;
  --blue-light:  #EFF6FF;
  --text:        #1E293B;
  --text-muted:  #64748B;
  --text-light:  #94A3B8;
  --border:      #E2E8F0;
  --surface:     #F8FAFC;
  --white:       #FFFFFF;
  --red:         #DC2626;
  --green:       #15803D;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "Courier New", monospace;

  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 25px rgba(0,0,0,0.10);
}

/* ── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: underline; }
a:hover { color: var(--blue); opacity: 0.8; }
a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 2px; }

img { max-width: 100%; height: auto; }

/* ── Header ────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.site-header .header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 96px;
  gap: 24px;
}

.site-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--white);
  flex-shrink: 0;
}

.site-header .logo-badge {
  width: 34px;
  height: 34px;
  background: var(--blue);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.site-header .logo-text {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.site-header .logo-text span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,0.55);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

.site-header nav a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  white-space: nowrap;
}

.site-header nav a:hover,
.site-header nav a.active {
  color: var(--white);
  background: rgba(255,255,255,0.1);
}

.site-header .btn-apply {
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s;
}

.site-header .btn-apply:hover { background: var(--gold-dark); color: var(--navy); }

/* ── Page Hero ─────────────────────────────────────────────────────────── */
.page-hero {
  background: var(--navy);
  padding: 48px 24px;
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.page-hero .hero-inner {
  max-width: 1280px;
  margin: 0 auto;
  position: relative;
}

.page-hero .eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 12px;
}

.page-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 12px;
}

.page-hero .subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,0.6);
  max-width: 600px;
}

.page-hero .meta {
  margin-top: 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.page-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 24px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 48px;
  align-items: start;
}

.page-layout.no-sidebar {
  grid-template-columns: 1fr;
  max-width: 960px;
}

/* ── Sidebar TOC ────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 88px;
}

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.toc h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.toc ol {
  list-style: none;
  counter-reset: toc-counter;
}

.toc ol li {
  counter-increment: toc-counter;
  margin-bottom: 2px;
}

.toc ol li a {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  line-height: 1.4;
  transition: all 0.12s;
}

.toc ol li a::before {
  content: counter(toc-counter);
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  background: var(--border);
  color: var(--text-muted);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.toc ol li a:hover {
  color: var(--blue);
  background: var(--blue-light);
}

.toc ol li a:hover::before {
  background: var(--blue);
  color: var(--white);
}

.toc .nmls-link {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.toc .nmls-link a { font-size: 12px; }

/* ── Content ────────────────────────────────────────────────────────────── */
.content { min-width: 0; }

.content section {
  margin-bottom: 48px;
  scroll-margin-top: 88px;
}

.content section:last-child { margin-bottom: 0; }

.content h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.content h2 .section-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--navy);
  color: var(--white);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.content h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--navy);
  margin-top: 24px;
  margin-bottom: 10px;
}

.content h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--navy-light);
  margin-top: 18px;
  margin-bottom: 8px;
}

.content p { margin-bottom: 14px; font-size: 0.9375rem; }
.content p:last-child { margin-bottom: 0; }

.content ul, .content ol {
  margin: 12px 0 16px 20px;
  font-size: 0.9375rem;
}

.content li { margin-bottom: 6px; line-height: 1.65; }

/* ── Callout Boxes ──────────────────────────────────────────────────────── */
.callout {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.callout-blue {
  background: var(--blue-light);
  border-left: 4px solid var(--blue);
  color: #1e3a6e;
}

.callout-gold {
  background: #FFFBEB;
  border-left: 4px solid var(--gold);
  color: #78350F;
}

.callout-green {
  background: #F0FDF4;
  border-left: 4px solid var(--green);
  color: #14532D;
}

.callout-red {
  background: #FEF2F2;
  border-left: 4px solid var(--red);
  color: #7F1D1D;
}

.callout strong { font-weight: 700; display: block; margin-bottom: 4px; }

/* ── GLBA Table ─────────────────────────────────────────────────────────── */
.glba-table-wrap { overflow-x: auto; margin: 20px 0; }

.glba-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.glba-table caption {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: left;
  padding: 8px 0;
  caption-side: bottom;
}

.glba-table thead tr {
  background: var(--navy);
  color: var(--white);
}

.glba-table thead th {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
}

.glba-table tbody tr { border-bottom: 1px solid var(--border); }
.glba-table tbody tr:last-child { border-bottom: none; }
.glba-table tbody tr:nth-child(even) { background: var(--surface); }

.glba-table td {
  padding: 12px 16px;
  vertical-align: top;
  line-height: 1.5;
}

.glba-table td:first-child { font-weight: 500; }

.badge-yes {
  display: inline-block;
  background: #DCFCE7;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.badge-no {
  display: inline-block;
  background: #F1F5F9;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

/* ── License Cards ─────────────────────────────────────────────────────── */
.license-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.license-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.license-card-header {
  background: var(--navy);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.state-abbr {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.license-card-header h3 {
  color: var(--white);
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 0;
}

.license-card-header p {
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  margin: 2px 0 0;
}

.license-card-body {
  padding: 20px;
}

.license-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  font-size: 13.5px;
}

.license-row:last-child { border-bottom: none; }

.license-row .lr-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  padding-top: 1px;
}

.license-row .lr-value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.license-row .lr-value a { font-size: 13px; }

.license-num {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-light);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* ── NMLS Badge ─────────────────────────────────────────────────────────── */
.nmls-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--navy);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  margin: 8px 0;
}

.nmls-badge:hover { background: var(--navy-mid); color: var(--white); opacity: 1; }

.nmls-badge .nmls-icon {
  background: var(--gold);
  color: var(--navy);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ── Equal Housing ──────────────────────────────────────────────────────── */
.equal-housing {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.eho-symbol {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  flex-shrink: 0;
}

/* ── Info Box (Placeholder) ─────────────────────────────────────────────── */
.placeholder {
  background: #FFFBEB;
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: #78350F;
  font-weight: 500;
  margin: 8px 0;
}

.placeholder::before { content: "⚠ PLACEHOLDER: "; font-weight: 700; }

/* ── Regulator List ─────────────────────────────────────────────────────── */
.regulator-list {
  list-style: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.regulator-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 0.875rem;
}

.regulator-list li strong { display: block; color: var(--navy); margin-bottom: 4px; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--navy);
  color: var(--white);
  margin-top: 80px;
}

.footer-top {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 24px 32px;
}

.footer-compliance {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 32px;
}

.footer-compliance h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 16px;
}

.footer-licenses {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.footer-license-pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  font-family: var(--font-mono);
}

.footer-disclosure {
  font-size: 11.5px;
  color: rgba(255,255,255,0.4);
  line-height: 1.7;
}

.footer-bottom {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-bottom .copyright {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
}

.footer-bottom .footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-bottom .footer-links a {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  text-decoration: none;
}

.footer-bottom .footer-links a:hover { color: var(--white); }

.footer-nmls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.footer-nmls-row a {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }

.last-updated {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.effective-date {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
  display: inline-block;
  margin-bottom: 24px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .page-layout {
    grid-template-columns: 1fr;
    padding: 32px 16px;
    gap: 32px;
  }

  .sidebar { position: static; }

  .toc { display: none; } /* Hide on mobile — consider a summary/details version */

  .license-grid { grid-template-columns: 1fr; }

  .site-header nav a { display: none; }
  .site-header .btn-apply { display: block; }
}

@media (max-width: 600px) {
  .page-hero { padding: 32px 16px; }
  .glba-table { font-size: 0.8125rem; }
  .glba-table td, .glba-table th { padding: 10px 12px; }
  .footer-top { padding: 32px 16px 24px; }
  .footer-bottom { padding: 16px; flex-direction: column; align-items: flex-start; }
}

/* ── Print ──────────────────────────────────────────────────────────────── */
@media print {
  .site-header { position: static; box-shadow: none; background: #000 !important; }
  .sidebar { display: none; }
  .page-layout { grid-template-columns: 1fr !important; }
  .page-hero { padding: 24px 0; background: #000 !important; }
  .site-footer { margin-top: 32px; background: #f0f0f0 !important; color: #000 !important; }
  .footer-compliance { background: #f0f0f0; border-color: #ccc; }
  .footer-disclosure, .footer-license-pill, .copyright, .footer-links a { color: #333 !important; }
  .content section { page-break-inside: avoid; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 11px; color: #555; }
  .glba-table { border: 1px solid #ccc; }
  .glba-table thead tr { background: #333 !important; }
}
