/* Custom Permits, Inc. — shared styles. See docs/build-plan.md Phase 1. */

:root {
  --accent: #185FA5;
  --accent-dark: #0C447C;
  --dark-section: #0c2b4a;
  --dark-section-text: #aec7de;
  --surface-1: #F4F5F7;
  --surface-2: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #5B6472;
  --border: #E4E7EB;
  --ok-bg: #E6F4EC;
  --ok-fg: #1B7F4B;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
body.nav-open { overflow: hidden; }

/* ---------- editorial markers ---------- */
.tbd {
  background: #FFF4D6;
  border-bottom: 1px dashed #C9A227;
  padding: 0 4px;
  border-radius: 2px;
  font-style: normal;
}
.draft {
  background: #E1EEFB;
  border-bottom: 1px dashed var(--accent);
  padding: 0 4px;
  border-radius: 2px;
  font-style: normal;
}

/* ---------- skip link ---------- */
/* First focusable element on every page (src/partials/nav.html). Moved off
   the top edge, never display:none or visibility:hidden, so it stays in the
   tab order. Fixed, not absolute, so focus reveals it in the same corner
   however far the page is scrolled. :focus rather than :focus-visible: an
   off-screen link can only be reached from the keyboard. See 10a. */
.skip-link {
  position: fixed; top: 8px; left: 16px; z-index: 200;
  transform: translateY(-200%);
  background: var(--accent); color: var(--surface-2);
  padding: 10px 16px; border-radius: 8px;
  font-size: 15px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { transform: none; }

/* ---------- nav ---------- */
nav { border-bottom: 1px solid var(--border); }
.nav-inner {
  display: flex;
  align-items: center;
  gap: 2.1vw;
  padding: 14px 3vw;
  max-width: 1900px;
  margin: 0 auto;
}
nav .logo { font-weight: 700; font-size: clamp(14px, 1.4vw, 19px); margin-left: 1.2vw; text-decoration: none; }
nav .nav-link { font-size: clamp(12px, 1.2vw, 16px); font-weight: 700; color: var(--text-secondary); text-decoration: none; }
nav .nav-link:hover { color: var(--text-primary); }
nav .nav-link.active { color: var(--text-primary); }
nav .phone { margin-left: auto; margin-right: 1.2vw; font-size: clamp(12px, 1.2vw, 16px); font-weight: 700; color: var(--accent); text-decoration: none; }
nav .cta-btn {
  font-size: clamp(12px, 1.2vw, 16px); font-weight: 700; background: var(--accent); color: #fff;
  padding: 9px 1.4vw; border-radius: 8px;
  text-decoration: none; white-space: nowrap; margin-right: 0.5vw;
}
nav .cta-btn:hover { background: var(--accent-dark); }

.nav-item { position: relative; }
.nav-item .dropdown-trigger { cursor: pointer; }
.services-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 14px;
  width: 620px;
  /* The panel sits ~190px from the left edge (measured 186px at 701px through
     205px at 1000px), so it must be capped against the viewport, not its own
     box — 230px covers that offset plus the scrollbar and a right gutter. */
  max-width: calc(100vw - 230px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  padding: 12px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, max-height 0.15s ease;
  z-index: 50;
}
.nav-item.open .services-dropdown {
  opacity: 1;
  max-height: 440px;
  pointer-events: auto;
}
.dropdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  text-decoration: none;
  transform: translateX(-26px);
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.45s ease, background-color 0.22s ease;
}
.nav-item.open .dropdown-item {
  transform: translateX(0);
  opacity: 1;
}
.dropdown-item:hover {
  background: var(--surface-1);
}
.dropdown-icon {
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: color 0.22s ease;
}
.dropdown-icon svg { width: 100%; height: 100%; display: block; }
.dropdown-item:hover .dropdown-icon {
  color: var(--accent);
}
.dropdown-text { display: flex; flex-direction: column; gap: 3px; }
.dropdown-title { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.dropdown-sub { font-weight: 400; font-size: 12px; line-height: 1.3; color: var(--text-secondary); }

/* ---------- mobile nav ---------- */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  margin-left: auto;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
}
.hamburger-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
}

.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--surface-2);
  z-index: 100;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  /* visibility flips instantly on open so focus can land, and is delayed on
     close so the overlay stays painted through the fade-out. */
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.mobile-nav-overlay.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.mobile-nav-logo { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--text-primary); }
.mobile-nav-close {
  border: none;
  background: none;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 4px;
}
.mobile-nav-close:hover { color: var(--text-primary); }

.mobile-nav-screens {
  position: relative;
  flex: 1;
  overflow: hidden;
}
.mobile-nav-screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 8px 20px 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.mobile-nav-screen-main { transform: translateX(0); opacity: 1; }
.mobile-nav-screen-services { transform: translateX(100%); opacity: 0; }
.mobile-nav-overlay.show-services .mobile-nav-screen-main { transform: translateX(-100%); opacity: 0; }
.mobile-nav-overlay.show-services .mobile-nav-screen-services { transform: translateX(0); opacity: 1; }

.mobile-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 4px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.mobile-nav-row .chevron { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.mobile-nav-phone {
  display: block;
  padding: 16px 4px;
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}
.mobile-nav-cta.btn-primary {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 20px;
  font-size: 16px;
  padding: 14px;
}

.mobile-nav-back {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  border: none;
  background: none;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 12px 4px;
  margin-bottom: 8px;
  cursor: pointer;
}
.mobile-nav-back svg { width: 16px; height: 16px; }

.mobile-service-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text-primary);
}
.mobile-service-row .dropdown-icon { width: 26px; height: 26px; }
.mobile-service-row .dropdown-title { font-size: 15px; }
.mobile-service-row .dropdown-sub { font-size: 13px; }

/* ---------- forms ---------- */
.hp { position: absolute; left: -9999px; }

.form-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px;
}
.field { margin-bottom: 22px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface-2);
  /* Field boundary, not a divider: --border is 1.24:1 on white and fails
     WCAG 1.4.11 for a control edge. 65% --text-secondary into --border is
     #8B929C, 3.14:1. --border itself is unchanged elsewhere. See 10a. */
  border: 1px solid color-mix(in srgb, var(--text-secondary) 65%, var(--border));
  border-radius: 8px;
  padding: 0 14px;
}
.field input,
.field select {
  height: 48px;
}
.field textarea {
  padding: 12px 14px;
  resize: vertical;
}
.field-help {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 6px 0 0;
}
.form-error {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 20px;
}
.form-noscript {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  margin: 0 0 24px;
}
.form-submit { margin-top: 4px; border: 0; font: inherit; cursor: pointer; }

.form-success h2 { font-size: 26px; font-weight: 700; margin: 0 0 10px; }
.form-success p { font-size: 16px; color: var(--text-secondary); margin: 0; }

@media (max-width: 700px) {
  .form-card { padding: 28px 24px; }
  .form-submit { display: block; width: 100%; text-align: center; }
}

/* ---------- shared layout / components ---------- */
.page-container { max-width: 1400px; margin: 0 auto; padding: 0 60px; }

/* Centred to match about.html's .intro, which is the reference treatment for
   a page opening. Shared by services, resources, and contact — all three
   centre together. The paragraph takes a narrower measure than the block so
   the lead doesn't run wider than the body copy it introduces; 620px matches
   .section-head below. See docs/build-plan.md 9c. */
.page-intro { max-width: 760px; margin: 0 auto; padding: 90px 0 70px; text-align: center; }
.page-intro h1 {
  font-size: 44px; font-weight: 700; line-height: 1.15;
  letter-spacing: -0.02em; margin: 0 0 20px;
}
.page-intro p {
  font-size: 18px; line-height: 1.65; color: var(--text-secondary);
  margin: 0 auto; max-width: 620px;
  /* Balances the last line. The 620px measure above left "have to." alone on
     line four of the Services intro, which reads as a mistake rather than a
     break. Deliberate, not a stray declaration. Browsers without support
     ignore it and wrap as they do today. */
  text-wrap: balance;
}

@media (max-width: 700px) {
  /* Reverts to left, matching about.html at the same breakpoint. Centred
     ragged-both-edges body text is harder to read at phone widths. This is
     deliberate — see docs/build-plan.md 9c. */
  .page-intro { padding: 60px 0 50px; text-align: left; }
  .page-intro h1 { font-size: 32px; }
  /* Drop the centred measure with the centring. Container padding falls to
     20px here, so the inner width is 660px at this breakpoint and the 620px
     cap would still bind — indenting the paragraph 20px from the h1 between
     661px and 700px. About's intro paragraph has no cap at any width. */
  .page-intro p { font-size: 17px; max-width: none; margin: 0; }
}
@media (max-width: 420px) {
  .page-intro h1 { font-size: 28px; }
}

h1, h2, h3 { text-wrap: balance; }

.section-head { max-width: 620px; margin: 0 0 48px; }
.section-head h2 {
  font-size: 40px; font-weight: 700; line-height: 1.15;
  letter-spacing: -0.02em; margin: 0 0 14px;
}
.section-head p { font-size: 17px; line-height: 1.6; color: var(--text-secondary); margin: 0; }

.btn-primary {
  font-size: clamp(12px, 1.15vw, 15px);
  background: var(--accent);
  color: #fff;
  padding: clamp(11px, 1.05vw, 15px) clamp(18px, 1.85vw, 26px);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-dark); }

.closing-cta {
  background: var(--dark-section);
  border-radius: 16px;
  padding: 56px 40px;
  text-align: center;
  margin: 0 0 40px;
}
.closing-cta h2 { color: #fff; font-size: 30px; font-weight: 700; margin: 0 0 10px; }
.closing-cta p { color: var(--dark-section-text); font-size: 15px; margin: 0 0 24px; }
.closing-cta p a { color: inherit; text-decoration: underline; }
/* The site's --accent ring is 2.2:1 on --dark-section; white is 14.38:1. */
.closing-cta :focus-visible { outline-color: var(--surface-2); }

/* ---------- footer ---------- */
footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px;
  padding: 34px 0; border-top: 1px solid var(--border);
}
footer .company { font-weight: 700; font-size: 15px; margin: 0 0 6px; }
footer .addr { font-size: 13px; color: var(--text-secondary); margin: 0 0 4px; }
footer .contact-info { font-size: 13px; color: var(--text-secondary); text-align: right; }
footer .contact-info p { margin: 0 0 4px; }
footer .contact-info a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ---------- responsive: shared chrome ---------- */
@media (max-width: 700px) {
  .nav-inner { padding: 14px 20px; justify-content: space-between; }
  nav .logo { font-size: 13px; }
  .nav-item, nav .nav-link, nav .phone, nav .cta-btn { display: none; }
  .hamburger { display: inline-flex; }
  .mobile-nav-overlay { display: flex; }
  .page-container { padding: 0 20px; }
  .section-head h2 { font-size: 30px; }
  .closing-cta { padding: 40px 24px; }
  footer .contact-info { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
