/* ============================================================
   JH APP GROUP · Shared site theme
   Imported by every page. Defines tokens, reset, nav, footer,
   typography, buttons, and common section chrome. Page-specific
   styles live inline in each HTML file.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Tokens (light default) ──────────────────────── */
:root {
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --bg: #F7F6F2;
  --fg: #0B0D12;
  --fg-muted: #6b7280;
  --fg-subtle: #9ca3af;
  --cream: #F7F6F2;
  --ink: #0B0D12;
  --ink-2: #1a1d27;
  --rule: rgba(11,13,18,.12);
  --rule-light: rgba(11,13,18,.08);
  --rule-dark: rgba(255,255,255,.1);

  --inv-bg: #0B0D12;
  --inv-fg: #ffffff;
  --inv-fg-muted: #9ca3af;
  --inv-rule: rgba(255,255,255,.1);
  --inv-surface: #1a1d27;
  --inv-logo: 1;
}

[data-theme="dark"] {
  --bg: #0B0D12;
  --fg: #F0EEE8;
  --fg-muted: #9ca3af;
  --fg-subtle: #6b7280;
  --cream: #14161D;
  --ink: #F0EEE8;
  --ink-2: #22252f;
  --rule: rgba(255,255,255,.12);
  --rule-light: rgba(255,255,255,.08);
  --rule-dark: rgba(11,13,18,.12);

  --inv-bg: #F7F6F2;
  --inv-fg: #0B0D12;
  --inv-fg-muted: #4b5563;
  --inv-rule: rgba(11,13,18,.12);
  --inv-surface: #ffffff;
  --inv-logo: 0;
}

/* ── Screen-reader only (a11y utility) ──────────
   Content visually hidden but exposed to screen readers. Used to seed
   heading hierarchy (e.g. a silent <h2>Site map</h2> in the footer so
   the footer's <h3> column headers don't jump the level tree). */
.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;
}

/* ── Focus ring (a11y) ──────────────────────────
   Visible focus outline on every interactive element. We render it as
   a 2px ring with an offset so it sits outside element borders. The
   `:focus-visible` pseudo only triggers for keyboard focus, not mouse
   clicks — matches modern browser default behavior. */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 4px;
}
[data-theme="dark"] :focus-visible { outline-color: var(--inv-fg); }

/* ── Reduced motion (a11y) ──────────────────────
   Respect OS-level "reduce motion" preference. Animations and
   transitions drop to near-zero duration so vestibular-sensitive
   users aren't affected by scroll reveals, pulse, or sweep animations. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Skip-to-content (a11y) ──────────────────────
   Keyboard users can jump past the nav on every page.
   Hidden off-screen until focused, then visually revealed. */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  padding: .625rem 1rem;
  background: var(--ink);
  color: var(--inv-fg);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  z-index: 100;
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus { top: 1rem; outline: 2px solid var(--ink); outline-offset: 2px; }

/* ── Reset ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; min-width: 0; }
html {
  scroll-behavior: smooth;
  /* Text-size-adjust on html + body prevents Android Chrome's auto-font
     inflation on pages it heuristically decides aren't "mobile-optimized"
     (even though <meta viewport> is set). Without this, body copy can
     render 10–15% larger on Android than the CSS specifies — which is
     exactly why the layout needed 90% page-zoom to "look right" before. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: var(--font-sans);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-feature-settings: "ss01", "cv11";
  line-height: 1.5;
  overflow-wrap: break-word;
  transition: background-color .3s ease, color .3s ease;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── Layout helpers ──────────────────────────────── */
.wrap { max-width: 1360px; margin: 0 auto; padding: 0 clamp(1.25rem, 3vw, 2.5rem); }
.mono { font-family: var(--mono); font-weight: 500; letter-spacing: .02em; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: .625rem;
}
.eyebrow::before {
  content: ""; width: 24px; height: 1px; background: currentColor;
}
.on-dark .eyebrow { color: var(--inv-fg-muted); }

/* ── Navigation ──────────────────────────────────── */
nav.top {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--rule-light);
  transition: background-color .3s ease;
}
nav .bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 82px;
}
nav .logo { display: flex; align-items: center; gap: .625rem; }
nav .logo img { height: 36px; }
/* Natural-color logos: blue in light theme, white in dark theme */
nav .logo .logo-dark { display: none; }
[data-theme="dark"] nav .logo .logo-light { display: none; }
[data-theme="dark"] nav .logo .logo-dark { display: inline-block; }
nav .logo b { display: none; }
nav .logo i { font-style: normal; font-family: var(--mono); font-size: 11px; color: var(--fg-muted); padding-left: .75rem; border-left: 1px solid var(--rule); margin-left: .25rem; }
nav .links { display: flex; gap: 2rem; font-size: 13px; font-weight: 500; }
nav .links a { color: var(--fg); position: relative; padding: .5rem 0; transition: opacity .15s; }
nav .links a:hover { opacity: .65; }
nav .links a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--fg);
}
nav .right { display: flex; align-items: center; gap: 1rem; }
nav .status { display: inline-flex; align-items: center; gap: .5rem; font-family: var(--mono); font-size: 11px; color: var(--fg-muted); }
/* Dot is decorative; aria-hidden below prevents SR from reading "bullet". */
nav .status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fg) 12%, transparent); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ── Theme toggle ────────────────────────────────── */
.theme-toggle {
  /* 44px ≥ WCAG 2.5.5 AAA tap target size. */
  width: 44px; height: 44px; border-radius: 9999px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  transition: border-color .15s, background .15s;
}
.theme-toggle:hover { border-color: var(--fg); }
.theme-toggle svg { position: absolute; transition: transform .4s cubic-bezier(.65,0,.35,1), opacity .3s; }
.theme-toggle .tt-sun { opacity: 0; transform: translateY(120%) rotate(40deg); }
.theme-toggle .tt-moon { opacity: 1; transform: translateY(0) rotate(0); }
[data-theme="dark"] .theme-toggle .tt-sun { opacity: 1; transform: translateY(0) rotate(0); }
[data-theme="dark"] .theme-toggle .tt-moon { opacity: 0; transform: translateY(-120%) rotate(-40deg); }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  /* Padding sized so total height ≥ 44px (WCAG 2.5.5). */
  padding: .875rem 1.25rem; font-size: 13px; font-weight: 600;
  min-height: 44px;
  border-radius: 9999px;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s, transform .15s, opacity .15s;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.btn-primary { background: var(--ink); color: var(--inv-fg); }
.btn-primary:hover { opacity: .88; }
.btn-ghost { border-color: var(--rule); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); }
.btn svg { width: 14px; height: 14px; }
.on-dark .btn-primary { background: #fff; color: #0B0D12; }
.on-dark .btn-primary:hover { background: #f3f4f6; }
.on-dark .btn-ghost { border-color: rgba(255,255,255,.22); color: var(--inv-fg); }
.on-dark .btn-ghost:hover { border-color: var(--inv-fg); background: rgba(255,255,255,.05); }

/* ── Section chrome ──────────────────────────────── */
/* Padding floor dropped from 4rem → 2.5rem so Android viewports
   (~384 CSS px) don't waste 64px of vertical chrome per section. */
section.pad { padding: clamp(2.5rem, 7vw, 7rem) 0; }
.on-dark { background: #0B0D12; color: #ffffff; }
[data-theme="dark"] .on-dark { background: var(--cream); color: var(--fg); }

.section-head {
  display: grid; grid-template-columns: 1fr 1.5fr;
  gap: 3rem; margin-bottom: 4rem; align-items: end;
}
.section-head .left .num {
  font-family: var(--mono); font-size: 11px; color: var(--fg-muted); margin-bottom: .75rem;
}
.on-dark .section-head .left .num { color: rgba(255,255,255,.55); }
[data-theme="dark"] .on-dark .section-head .left .num { color: var(--fg-muted); }
.section-head h2 {
  /* Floor dropped from 2rem → 1.625rem to prevent oversized headings
     on Android viewports ~384 CSS px. Ceiling unchanged. */
  font-size: clamp(1.625rem, 4vw, 3.25rem); font-weight: 700;
  letter-spacing: -.025em; line-height: 1.02; color: var(--ink); max-width: 12ch;
}
.on-dark .section-head h2 { color: #fff; }
[data-theme="dark"] .on-dark .section-head h2 { color: var(--fg); }
.section-head .right p { font-size: 1.0625rem; line-height: 1.6; color: var(--fg-muted); max-width: 48ch; }
.on-dark .section-head .right p { color: rgba(255,255,255,.65); }
[data-theme="dark"] .on-dark .section-head .right p { color: var(--fg-muted); }

/* ── Footer ──────────────────────────────────────── */
/* Footer adopts the page theme: cream bg + dark text in light mode,
   dark bg + light text in dark mode. Logo swaps blue/white accordingly. */
footer.site {
  background: var(--bg); color: var(--fg-muted); padding: 4rem 0 2rem;
  border-top: 1px solid var(--rule);
}
.footer-top { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 3rem; padding-bottom: 3rem; border-bottom: 1px solid var(--rule); }
.footer-brand img { height: 24px !important; margin-bottom: 1rem; width: auto !important; max-width: 100% !important; }
.footer-brand .logo-dark { display: none; }
[data-theme="dark"] .footer-brand .logo-light { display: none; }
[data-theme="dark"] .footer-brand .logo-dark { display: inline-block; }
.footer-brand p { color: var(--fg-muted); font-size: .875rem; line-height: 1.6; max-width: 32ch; }
footer.site h3 { color: var(--ink); font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .12em; margin-bottom: 1rem; font-weight: 600; }
footer.site ul { list-style: none; display: flex; flex-direction: column; gap: .625rem; }
footer.site ul a { font-size: .875rem; color: var(--fg-muted); transition: color .15s; }
footer.site ul a:hover { color: var(--ink); }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; padding-top: 2rem; font-size: 12px; font-family: var(--mono); color: var(--fg-muted); flex-wrap: wrap; gap: 1rem; }
.footer-bottom .tag { color: var(--ink); }

/* ── Utility: reveal-on-scroll ───────────────────── */
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .6s ease, transform .6s cubic-bezier(.25,.8,.25,1); }
.reveal.in { opacity: 1; transform: none; }

/* ── Mobile nav toggle + panel ─────────────────────
   The hamburger button + slide-down panel are injected by theme.js on
   every page; styles live here so all pages share a consistent chrome.
   Desktop (>1024px): toggle hidden, inline links visible.
   Tablet/mobile (<=1024px): inline links hidden, toggle visible, panel
   slides down from under the nav bar when open. */
.nav-toggle {
  display: none;
  width: 40px; height: 40px; border-radius: 9999px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  align-items: center; justify-content: center;
  transition: border-color .15s, background .15s;
  padding: 0;
}
.nav-toggle:hover { border-color: var(--fg); }
.nav-toggle svg { width: 18px; height: 18px; }
.nav-toggle .nt-close { display: none; }
.nav-toggle[aria-expanded="true"] .nt-open { display: none; }
.nav-toggle[aria-expanded="true"] .nt-close { display: block; }

.nav-mobile-panel {
  display: none;
  position: fixed;
  top: 82px; left: 0; right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  z-index: 49;
  box-shadow: 0 18px 40px -20px rgba(11,13,18,.28);
  max-height: calc(100vh - 82px);
  overflow-y: auto;
}
[data-theme="dark"] .nav-mobile-panel {
  box-shadow: 0 18px 40px -20px rgba(0,0,0,.6);
}
.nav-mobile-panel.open { display: block; }
.nav-mobile-panel ul { list-style: none; padding: .75rem 0 .25rem; margin: 0; }
.nav-mobile-panel li { border-top: 1px solid var(--rule-light); }
.nav-mobile-panel li:first-child { border-top: none; }
.nav-mobile-panel a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.125rem clamp(1.25rem, 3vw, 2.5rem);
  font-size: 15px; font-weight: 500; color: var(--fg);
  min-height: 48px;
}
.nav-mobile-panel a::after {
  content: "→"; font-family: var(--mono);
  color: var(--fg-muted); font-size: 13px;
}
.nav-mobile-panel a:hover { background: var(--cream); }
.nav-mobile-panel a[aria-current="page"] { font-weight: 700; }
.nav-mobile-panel a[aria-current="page"]::after { color: var(--ink); }
/* Primary CTA block at the bottom of the panel — prominent pill so
   narrow-viewport users who don't see the inline nav CTA still get a
   clear entry point. */
.nav-mobile-cta {
  padding: 1rem clamp(1.25rem, 3vw, 2.5rem) 1.5rem;
  border-top: 1px solid var(--rule-light);
}
.nav-mobile-cta .btn { width: 100%; justify-content: center; }
.nav-mobile-cta .btn::after { content: none; }

/* Prevent body scroll when the panel is open. */
body.nav-open { overflow: hidden; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1024px) {
  nav .links { display: none; }
  nav .status { display: none; }
  .nav-toggle { display: inline-flex; }
  .section-head { grid-template-columns: 1fr; gap: 1.5rem; margin-bottom: 3rem; }
  .footer-top { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .footer-top { grid-template-columns: 1fr; }
  nav .logo i { display: none; }
  /* On narrow phones, collapse "Start a project" to an icon-only CTA so
     the nav doesn't overflow the logo. The svg arrow carries the meaning;
     the aria-label on the link element provides screen-reader text. */
  nav .right .btn-primary span.cta-label,
  nav .right .btn-primary {
    font-size: 12px;
  }
  nav .right .btn-primary {
    padding: .625rem .875rem;
  }
  nav .logo img { height: 30px; }
  nav .bar { height: 70px; }
  .nav-mobile-panel { top: 70px; max-height: calc(100vh - 70px); }
}
@media (max-width: 420px) {
  /* At narrow Android viewports (~384 CSS px — Galaxy S-series at
     100% Chrome zoom with Display Size bumped above default), the
     right-side cluster (hamburger + toggle + CTA) needs to fit
     alongside the logo with visible breathing room. Keep the CTA
     VISIBLE but compact: smaller padding, smaller font, arrow hidden. */
  nav .right { gap: .5rem; }
  nav .logo img { height: 26px; }
  nav .bar { height: 64px; }
  .nav-mobile-panel { top: 64px; max-height: calc(100vh - 64px); }
  nav .right .btn-primary {
    padding: .5rem .75rem;
    font-size: 11px;
    min-height: 40px;
    gap: .375rem;
  }
  nav .right .btn-primary svg { width: 12px; height: 12px; }
}

/* ── USCIS non-affiliation banner ────────────────────
   Required on every page that references CaseFlow for
   USCIS demo compliance. Sits directly under nav.top.
   Amber on light, muted gold on dark — 4.5:1 contrast
   maintained in both themes. */
.uscis-banner {
  background: #FEF3C7;
  border-bottom: 1px solid #F59E0B;
  color: #78350F;
}
[data-theme="dark"] .uscis-banner {
  background: #3F2E07;
  border-bottom: 1px solid #B45309;
  color: #FEF3C7;
}
.uscis-banner .wrap {
  padding: .875rem 1.5rem;
  display: flex;
  gap: .875rem;
  align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.5;
}
.uscis-banner strong { font-weight: 700; }
.uscis-banner .uscis-icon {
  flex: 0 0 18px;
  padding-top: 2px;
}
.uscis-banner a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
@media (max-width: 640px) {
  .uscis-banner .wrap { padding: .75rem 1rem; font-size: 13px; }
}
