/* =====================================================================
   MoreLaw UI system: css/ui.css (proposal, 2026-11-24)
   Load AFTER bootstrap.min.css, the inlined styles.css, styles-new.css
   and htmx-styles.css (template_top.php). Cascade follows source order.

   Rules for this file:
   - Section 1 (tokens) and section 2 (ml-* components) are OPT-IN. Nothing
     here selects an existing Bootstrap or legacy class, so loading the file
     changes no pixel on any page (package U1 QA = identical screenshots).
   - Every value comes from the dominant existing usage on the live site
     (counts in reports/ui/UI-SYSTEM.md section 1). No new brand colours.
   - Only Sanchez 400 ships (/fonts/sanchez/sanchez-regular.woff2); "bold"
     is synthesised. Do not add 500/600 weights.
   - Custom properties cannot be used inside @media conditions, so the
     breakpoints are documented as tokens but written as literals.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. TOKENS
   --------------------------------------------------------------------- */
:root {
  /* Colour: brand */
  --ml-navy: #06357a;            /* navbar/sidebar titles, outline buttons: 774 text + 59 bg + 720 borders */
  --ml-flag-red: #bf0a30;        /* pinstripe + logo "M": every page */
  --ml-flag-blue: #002868;       /* pinstripe + logo "L": every page */

  /* Colour: action (Bootstrap primary; 1,463 link texts, 192 bg) */
  --ml-action: #0d6efd;          /* filled buttons, page banners, links on white (4.50:1) */
  --ml-action-strong: #0a58ca;   /* hover, and links on tinted surfaces (5.75:1 on #f2f2f2) */
  --ml-on-action: #ffffff;

  /* Colour: commerce */
  --ml-paid: #198754;            /* "Enhanced" badge, upgrade button (BS success; white text 4.53:1) */
  --ml-paid-strong: #146c43;     /* hover/pressed, text-on-white (6.45:1) */
  --ml-paid-tint: #d1e7dd;
  --ml-star: #ffc107;            /* "Best Lawyers" star (text-warning) */

  /* Colour: text and surfaces */
  --ml-text: #212529;            /* 791 elements */
  --ml-text-muted: rgba(33, 37, 41, 0.75); /* 408 elements, 6.76:1 on white */
  --ml-page-bg: #f2f2f2;         /* body.bg-grey = rgba(0,0,0,.05) on white */
  --ml-surface: #ffffff;         /* 577 elements */
  --ml-surface-alt: #f8f9fa;     /* 153 elements: ad slots, card footers */
  --ml-border: #dee2e6;          /* Bootstrap border colour */
  --ml-border-card: rgba(0, 0, 0, 0.175); /* Bootstrap .card border */

  /* Colour: feedback (Bootstrap 5 alert palette, already loaded) */
  --ml-info-bg: #cff4fc;   --ml-info-text: #055160;
  --ml-success-bg: #d1e7dd; --ml-success-text: #0a3622;
  --ml-warning-bg: #fff3cd; --ml-warning-text: #664d03;
  --ml-danger: #dc3545;    --ml-danger-bg: #f8d7da; --ml-danger-text: #58151c;

  /* Focus */
  --ml-focus-ring: 0 0 0 0.25rem rgba(13, 110, 253, 0.25); /* Bootstrap focus ring */
  --ml-focus-outline: 2px solid var(--ml-navy);

  /* Typography (Sanchez on 4,287 of ~4,333 text elements) */
  --ml-font: 'Sanchez', serif;
  --ml-fs-2xs: 0.625rem;   /* 10px  ad label (8 elements) */
  --ml-fs-sm: 0.875rem;    /* 14px  meta, small buttons (1,012) */
  --ml-fs-base: 1rem;      /* 16px  body (2,516) */
  --ml-fs-lg: 1.2rem;      /* 19.2px nav links (212) */
  --ml-fs-title: 1.25rem;  /* 20px  card/listing names, h5 (241) */
  --ml-fs-h3: 1.5rem;      /* 24px  section sub-heads */
  --ml-fs-h2: 2rem;        /* 32px  section heads (103) */
  --ml-fs-h1: calc(1.375rem + 1.5vw); /* Bootstrap h1; 2.5rem from 1200px (40px desktop, 21 on 16 templates) */
  --ml-lh: 1.5;
  --ml-lh-tight: 1.2;
  --ml-fw: 400;
  --ml-fw-bold: 700;       /* synthesised; only weight 400 is shipped */

  /* Spacing (Bootstrap spacer scale: mb-3 x168, mb-2 x90) */
  --ml-space-1: 0.25rem;   /* 4  */
  --ml-space-2: 0.5rem;    /* 8  */
  --ml-space-3: 1rem;      /* 16 */
  --ml-space-4: 1.5rem;    /* 24 */
  --ml-space-5: 3rem;      /* 48 */

  /* Shape */
  --ml-radius: 0.375rem;     /* 6px: 1,037 elements */
  --ml-radius-sm: 0.25rem;   /* 4px: 217 (btn-sm) */
  --ml-radius-lg: 0.5rem;    /* 8px: 62 (btn-lg) */
  --ml-radius-pill: 50rem;
  --ml-shadow-none: none;    /* the site is flat: 0 shadows outside the upgrade page */
  --ml-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075); /* Bootstrap shadow-sm, hover only */
  --ml-shadow-md: 0 5px 15px rgba(0, 0, 0, 0.08);          /* upgrade page cards (5 elements) */

  /* Sizing */
  --ml-tap: 44px;            /* minimum touch target below 768px */
  --ml-control-h: 38px;      /* Bootstrap default .btn/.form-control height (desktop) */
  --ml-sidebar-w: 280px;     /* .main-layout grid column */
  --ml-gutter: 30px;         /* .main-layout gap */

  /* Breakpoints (documentation only; use literals in @media):
     sm 576px, md 768px, lg 992px, xl 1200px  (Bootstrap 5).
     Retire 480/767/991 duplicates in styles-new.css and 768 in htmx-styles.css. */
}

/* ---------------------------------------------------------------------
   2. COMPONENTS (all opt-in, ml- prefix)
   --------------------------------------------------------------------- */

/* 2.1 Buttons ---------------------------------------------------------- */
.ml-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ml-space-2);
  min-height: var(--ml-control-h);
  padding: 0.375rem 0.75rem;              /* 6px 12px, the dominant button */
  font: var(--ml-fw) var(--ml-fs-base)/var(--ml-lh) var(--ml-font);
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  border: 1px solid transparent;
  border-radius: var(--ml-radius);
  cursor: pointer;
  user-select: none;
  transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s;
}
.ml-btn:focus-visible { outline: var(--ml-focus-outline); outline-offset: 2px; box-shadow: var(--ml-focus-ring); }
.ml-btn[disabled], .ml-btn[aria-disabled="true"] { opacity: .65; pointer-events: none; }

.ml-btn--primary   { color: var(--ml-on-action); background: var(--ml-action); border-color: var(--ml-action); }
.ml-btn--primary:hover { color: var(--ml-on-action); background: var(--ml-action-strong); border-color: var(--ml-action-strong); }

.ml-btn--secondary { color: var(--ml-navy); background: transparent; border-color: var(--ml-navy); }
.ml-btn--secondary:hover { color: #fff; background: var(--ml-navy); }

.ml-btn--upgrade   { color: #fff; background: var(--ml-paid); border-color: var(--ml-paid); }
.ml-btn--upgrade:hover { color: #fff; background: var(--ml-paid-strong); border-color: var(--ml-paid-strong); }

.ml-btn--link {
  color: var(--ml-action); background: transparent; border-color: transparent;
  text-decoration: underline; text-underline-offset: 2px;
}
.ml-btn--link:hover { color: var(--ml-action-strong); }

.ml-btn--sm { min-height: 31px; padding: 0.25rem 0.5rem; font-size: var(--ml-fs-sm); border-radius: var(--ml-radius-sm); }
.ml-btn--lg { min-height: 48px; padding: 0.5rem 1rem; font-size: var(--ml-fs-title); border-radius: var(--ml-radius-lg); }
.ml-btn--block { display: flex; width: 100%; }

@media (max-width: 767.98px) {
  .ml-btn, .ml-btn--sm { min-height: var(--ml-tap); }
  .ml-btn--lg { white-space: normal; }
}

/* 2.2 Paid badge ------------------------------------------------------- */
.ml-badge {
  display: inline-block;
  padding: 0.25em 0.6em;
  font-size: 0.75em;
  font-weight: var(--ml-fw);
  line-height: 1.2;
  letter-spacing: .02em;
  white-space: nowrap;
  vertical-align: 0.15em;
  border-radius: var(--ml-radius);
}
.ml-badge--paid { color: #fff; background: var(--ml-paid); }
.ml-badge--paid::before { content: "\2713\00a0"; } /* check mark, decorative; text "Enhanced" carries meaning */

/* 2.3 Listing card (lawyer / expert / reporter) ------------------------ */
.ml-listing {
  position: relative;
  margin-bottom: var(--ml-space-3);
  padding: var(--ml-space-3);
  color: var(--ml-text);
  background: var(--ml-surface);
  border: 1px solid var(--ml-border-card);
  border-radius: var(--ml-radius);
}
.ml-listing__name {
  margin: 0 0 var(--ml-space-2);
  font-size: var(--ml-fs-title);
  font-weight: var(--ml-fw);
  line-height: var(--ml-lh-tight);
}
.ml-listing__name a { color: var(--ml-action); text-decoration: underline; text-underline-offset: 2px; }
.ml-listing__name a:hover { color: var(--ml-action-strong); }
.ml-listing__name .ml-badge { margin-left: var(--ml-space-2); font-size: 0.7rem; }
.ml-listing__firm { margin: 0 0 var(--ml-space-1); color: var(--ml-text); }
.ml-listing__meta { margin: 0 0 var(--ml-space-2); font-size: var(--ml-fs-sm); color: var(--ml-text-muted); }
.ml-listing__meta .fas { width: 1em; text-align: center; }
.ml-listing__phone { margin: 0 0 var(--ml-space-2); }
.ml-listing__phone a { color: var(--ml-text); text-decoration: none; }
.ml-listing__phone a:hover { text-decoration: underline; }
.ml-listing__practice { margin: 0 0 var(--ml-space-2); font-size: var(--ml-fs-sm); color: var(--ml-text-muted); }
.ml-listing__actions { display: flex; flex-wrap: wrap; gap: var(--ml-space-2); margin-top: var(--ml-space-2); }
.ml-listing__claim { margin: var(--ml-space-2) 0 0; font-size: var(--ml-fs-sm); }
.ml-listing__claim a { color: var(--ml-action); }

/* Paid variant (NEEDS JOEL J2 picks how much of this ships) */
.ml-listing--paid { border-left: 4px solid var(--ml-paid); padding-left: calc(var(--ml-space-3) - 3px); }

@media (max-width: 575.98px) {
  .ml-listing__actions .ml-btn { flex: 1 1 auto; }
}

/* 2.4 Upgrade / claim CTA (profile footer) ----------------------------- */
.ml-cta {
  margin-top: var(--ml-space-3);
  padding: var(--ml-space-3);
  text-align: center;
  background: var(--ml-surface-alt);
  border-top: 1px solid var(--ml-border-card);
  border-radius: 0 0 var(--ml-radius) var(--ml-radius);
}
.ml-cta a:not(.ml-btn) { color: var(--ml-action-strong); }
.ml-cta__title { margin: 0 0 var(--ml-space-2); font-size: var(--ml-fs-title); font-weight: var(--ml-fw); }
.ml-cta__price { color: var(--ml-paid-strong); font-weight: var(--ml-fw-bold); }
.ml-cta__claim { margin: var(--ml-space-2) 0 0; }
.ml-cta__help { margin: var(--ml-space-1) 0 0; font-size: var(--ml-fs-sm); color: var(--ml-text-muted); }

/* 2.5 Contact block (profile) ------------------------------------------ */
.ml-contact { display: flex; flex-wrap: wrap; gap: var(--ml-space-2); margin: var(--ml-space-3) 0; }

/* 2.6 Page header (blue banner with the page H1) ----------------------- */
.ml-page-header {
  margin-bottom: var(--ml-space-4);
  padding: var(--ml-space-4);
  color: var(--ml-on-action);
  background: var(--ml-action);
  border-radius: var(--ml-radius);
}
.ml-page-header__title { margin: 0 0 1rem; font-size: var(--ml-fs-h1); font-weight: var(--ml-fw); line-height: var(--ml-lh-tight); color: inherit; }
.ml-page-header--center { text-align: center; }
@media (min-width: 1200px) { .ml-page-header__title, .ml-title { font-size: 2.5rem; } }
.ml-page-header__lead { margin: 0 0 var(--ml-space-2); }
.ml-page-header__lead .fa-star { color: var(--ml-star); }
.ml-page-header__meta { margin: 0; font-size: var(--ml-fs-sm); }
.ml-page-header a { color: #fff; text-decoration: underline; }
.ml-page-header a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Plain page title (no banner): account and static pages */
.ml-title { margin: 0 0 var(--ml-space-3); font-size: var(--ml-fs-h1); font-weight: var(--ml-fw); line-height: var(--ml-lh-tight); color: var(--ml-text); }
.ml-section-title { margin: var(--ml-space-4) 0 var(--ml-space-3); font-size: var(--ml-fs-h3); font-weight: var(--ml-fw); line-height: var(--ml-lh-tight); }

/* 2.7 Sidebar panel title (navy bar: "Find a Lawyer") ------------------ */
.ml-panel-title {
  margin: 0 0 var(--ml-space-3);
  padding: var(--ml-space-2);
  font-size: var(--ml-fs-base);
  font-weight: var(--ml-fw-bold);
  color: #fff;
  background: var(--ml-navy);
}

/* 2.8 Forms (search + account) ----------------------------------------- */
.ml-form { max-width: 32rem; }
.ml-form--wide { max-width: none; }
.ml-field { margin-bottom: var(--ml-space-3); }
.ml-label { display: block; margin-bottom: var(--ml-space-1); color: var(--ml-text); }
.ml-label .ml-req { color: var(--ml-danger); }
.ml-input, .ml-select {
  display: block;
  width: 100%;
  min-height: var(--ml-control-h);
  padding: 0.375rem 0.75rem;
  font: var(--ml-fw) var(--ml-fs-base)/var(--ml-lh) var(--ml-font);
  color: var(--ml-text);
  background-color: #fff;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
}
.ml-select { appearance: auto; }
.ml-input:focus, .ml-select:focus { border-color: #86b7fe; outline: 0; box-shadow: var(--ml-focus-ring); }
.ml-input[aria-invalid="true"] { border-color: var(--ml-danger); }
.ml-help { margin-top: var(--ml-space-1); font-size: var(--ml-fs-sm); color: var(--ml-text-muted); }
.ml-error { margin-top: var(--ml-space-1); font-size: var(--ml-fs-sm); color: var(--ml-danger-text); }
.ml-form__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ml-space-3); margin-top: var(--ml-space-3); }
.ml-form__links { margin: var(--ml-space-3) 0 0; padding: 0; list-style: none; font-size: var(--ml-fs-sm); }
.ml-form__links li { margin-bottom: var(--ml-space-1); }
.ml-search { padding: var(--ml-space-3); background: var(--ml-surface); border: 1px solid var(--ml-border-card); border-radius: var(--ml-radius); }
.ml-search__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0 var(--ml-space-3); }
.ml-search--sidebar { padding: 0; border: 0; background: transparent; }
@media (max-width: 767.98px) {
  .ml-input, .ml-select { min-height: var(--ml-tap); }
  .ml-form__actions .ml-btn { width: 100%; }
}

/* 2.9 Alerts and empty state (Bootstrap .alert stays canonical; this adds the empty-state layout) */
.ml-empty { padding: var(--ml-space-3); color: var(--ml-info-text); background: var(--ml-info-bg); border-radius: var(--ml-radius); }
.ml-empty__title { margin: 0 0 var(--ml-space-2); font-size: var(--ml-fs-title); font-weight: var(--ml-fw); }
.ml-empty__actions { display: flex; flex-wrap: wrap; gap: var(--ml-space-2); margin: var(--ml-space-2) 0 0; }
.ml-empty a { color: #032830; }

/* 2.10 Record list (verdicts, cases, news) ----------------------------- */
.ml-records { margin: 0 0 var(--ml-space-3); padding: 0; list-style: none; background: var(--ml-surface); border: 1px solid var(--ml-border); border-radius: var(--ml-radius); }
.ml-record { padding: var(--ml-space-2) var(--ml-space-3); border-top: 1px solid var(--ml-border); }
.ml-record:first-child { border-top: 0; }
.ml-record__title { margin: 0 0 var(--ml-space-1); color: var(--ml-text); font-size: var(--ml-fs-title); font-weight: var(--ml-fw); line-height: var(--ml-lh-tight); overflow-wrap: anywhere; }
.ml-record__title a { color: var(--ml-action); }
.ml-record__meta { margin: 0 0 var(--ml-space-2); font-size: var(--ml-fs-sm); color: var(--ml-text-muted); }
.ml-record__excerpt { margin: 0 0 var(--ml-space-2); overflow-wrap: anywhere; }
.ml-record__amount { color: var(--ml-paid-strong); font-weight: var(--ml-fw-bold); }

/* 2.11 Pagination ------------------------------------------------------ */
.ml-pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--ml-space-2); margin: var(--ml-space-4) 0; padding: 0; list-style: none; }
.ml-pager__status { padding: 0 var(--ml-space-2); color: var(--ml-text-muted); }
.ml-pager [aria-current="page"] { color: #fff; background: var(--ml-navy); border-color: var(--ml-navy); }

/* 2.12 Tile grid (city / practice / state link grids; replaces btn-block) */
.ml-tiles { display: grid; grid-template-columns: 1fr; gap: 1rem 1.5rem; margin: 0 0 var(--ml-space-4); padding: 0; list-style: none; }
.ml-tiles .ml-btn { width: 100%; }
@media (min-width: 576px) { .ml-tiles { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .ml-tiles { grid-template-columns: repeat(3, 1fr); } }

/* 2.13 Ad container --------------------------------------------------
   Box metrics (min-height, margin, padding, border, mobile overrides) stay
   canonical in styles-new.css (.ad-banner-header, .ad-sidebar, .ad-in-article,
   .ad-content-bottom) so the <ins> geometry, and therefore the ad sizes served,
   do not change. These classes only replace the inline style="" attributes
   with byte-equivalent rules. */
.ml-ad-inline { background: var(--ml-surface-alt); border-radius: var(--ml-radius-sm); } /* ads.php:180 */
.ml-ad-label  { font-size: var(--ml-fs-2xs); letter-spacing: 1px; }                     /* ads.php:182 */
.ml-ad-rule   { border-top: 1px solid #eee; border-bottom: 1px solid #eee; }             /* template_bottom.php:193 */
.ml-sidebar-sticky { position: sticky; top: 70px; } /* template_bottom.php:161; styles-new mobile override (static !important) still applies */

/* 2.14 Skip link ------------------------------------------------------- */
.ml-skip-link:focus { color: var(--ml-navy); background: #fff; outline: var(--ml-focus-outline); }

/* 2.15 Modal (Bootstrap 5 .modal + this opt-in hook) ------------------- */
.ml-modal .modal-title { font-size: var(--ml-fs-title); font-weight: var(--ml-fw); }
@media (max-width: 767.98px) {
  .ml-modal .btn-close { width: var(--ml-tap); height: var(--ml-tap); padding: 0; }
}

/* 2.16 Navbar hamburger tap target (U1 step 4; mobile only) ------------ */
@media (max-width: 991.98px) {
  .ml-nav-toggle { min-width: 44px; min-height: 44px; }
}
