/* components.css — reusable UI: header, hero, cards, steps, form, footer.
   Mobile-first: base rules target ~320px, then min-width breakpoints layer
   up for tablet (768px) and desktop (1024px). */

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--side-pad);
}

/* ---------- Utilities ---------- */

.text-center {
  text-align: center;
}

.mt-lg {
  margin-top: 2rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1.75rem;
  font-weight: 600;
  font-size: 0.88rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-primary);
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--color-section-bg);
  transform: translateY(-1px);
}

.btn-solid {
  background: var(--color-primary);
  color: var(--color-accent);
}
.btn-solid:hover,
.btn-solid:focus-visible {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  /* Extend the solid header background into the iOS status-bar / notch
     area instead of leaving it to html/body (a top offset there would
     push the sticky header down and reopen the gap). */
  padding-top: env(safe-area-inset-top, 0px);
  /* Forces GPU compositing so Safari keeps the sticky element pinned to
     the very top of the visual viewport instead of lagging a frame
     behind during the address-bar collapse/expand animation, which is
     what let hero content flash through above the header. */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-logo {
  width: 70px;
  height: 70px;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.45rem;
  color: var(--color-primary);
}

.header-contact-link {
  font-weight: 600;
  font-size: 0.836rem;
  padding: 0.6rem 1.1rem;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.header-contact-link:hover,
.header-contact-link:focus-visible {
  background: var(--color-primary);
  color: var(--color-accent);
}

/* ---------- Hero ---------- */

.hero {
  background: var(--color-primary);
  color: var(--color-accent);
  padding: clamp(3rem, 8vw, 6rem) 0;
}

.hero-inner {
  max-width: 44rem;
}

.hero-title {
  color: var(--color-accent);
  margin-bottom: 1.25rem;
}

.hero-subtitle {
  color: var(--color-accent);
  opacity: 0.92;
  max-width: 40rem;
  margin-bottom: 2rem;
}

.hero-tagline {
  color: var(--color-accent);
  opacity: 0.8;
  font-size: 0.836rem;
  margin-top: 1rem;
}

/* ---------- Sections (generic) ----------
   Vertical rhythm runs on explicit tokens: --section-padding-y (full
   padding-top AND padding-bottom on every section, redefined at 768px/
   1024px in the breakpoints below) and --section-gap-title (space from
   a section's heading to its content). No margins are added on top of
   this padding, so the gap between any two adjacent sections is simply
   the sum of their two paddings — deliberately, uniformly, everywhere,
   including the Outsourcing -> Contact seam. */

.section {
  padding-top: var(--section-padding-y);
  padding-bottom: var(--section-padding-y);
}

.section--alt {
  background: var(--color-section-bg);
}

#contact {
  /* Anchor target is the form heading itself (not the outer section box),
     so jumping here lands with exactly a 24px gap below the sticky
     header on every screen size, not the section's own top padding. */
  scroll-margin-top: calc(var(--header-height) + env(safe-area-inset-top, 0px) + 24px);
}

.section-title {
  text-align: center;
  margin-bottom: var(--section-gap-title);
}

.section-intro {
  text-align: center;
  color: var(--color-text-muted);
  max-width: 40rem;
  margin: 0 auto 2.5rem;
}

/* ---------- Card grids (Services / Who We Serve / Why Gorod) ---------- */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.card {
  background: var(--color-bg);
  border-radius: var(--radius-card);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.service-icon {
  width: 32px;
  height: 32px;
  color: var(--color-primary);
  margin-bottom: 1rem;
}

.card-title {
  margin-bottom: 0.5rem;
  font-size: 1.4375rem;
  /* Reserve space for two lines regardless of actual line count, so a
     card whose title wraps (e.g. "Payment Tracking & Recordkeeping")
     doesn't push its description lower than its neighbors'. */
  min-height: 2.4em;
}

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

/* ---------- Who We Serve (no cards — columns divided by a thin rule) ---------- */

.who-list {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
}

.who-item {
  text-align: center;
  padding: 1.5rem 0;
  border-top: 1px solid var(--color-border);
}
.who-item:first-child {
  border-top: none;
  padding-top: 0;
}

.who-item-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.4375rem;
  margin-bottom: 0.5rem;
  /* Reserve two lines so a wrapped title (narrow tablet columns) doesn't
     push that column's description lower than its neighbors'. */
  min-height: 2.4em;
}

.who-item-text {
  color: var(--color-text-muted);
}

/* ---------- Why Gorod (no cards, no borders — compact term/description list) ---------- */

.why-list {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 1rem;
  margin: 0;
}

.why-item {
  display: block;
}

.why-item-title {
  display: block;
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 0.25rem;
}

.why-item-text {
  display: block;
  text-wrap: pretty;
  color: var(--color-text-muted);
  margin: 0;
}

/* ---------- How It Works ---------- */

.steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  counter-reset: step;
}

.step {
  text-align: center;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-accent);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 auto 1rem;
}

.step-title {
  margin-bottom: 0.4rem;
  font-size: 1.375rem;
}

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

/* ---------- Outsourcing vs. In-House ---------- */

.outsourcing-text {
  max-width: 46rem;
  margin: 0 auto;
  text-align: center;
  font-size: clamp(1.155rem, 0.55vw + 1.1rem, 1.375rem);
  color: var(--color-text);
}

/* ---------- Outsourcing vs. In-House comparison table ----------
   Mobile-first: base rules stack each row into its own bordered card
   (label, then In-House value, then Gorod value). A real <table> layout
   only kicks in at >=768px (see tablet breakpoint below). */

.compare-wrap {
  max-width: 50rem;
  margin: 2.5rem auto 0;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  text-wrap: pretty;
}

.compare-table thead {
  display: none;
}

.compare-table,
.compare-table tbody,
.compare-table tr,
.compare-table th,
.compare-table td {
  display: block;
  width: 100%;
}

.compare-table tbody tr {
  margin-bottom: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.compare-table tbody tr:last-child {
  margin-bottom: 0;
}

.compare-table th,
.compare-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.compare-table tbody tr td:last-child {
  border-bottom: none;
}

.compare-table tbody th {
  font-weight: 700;
  color: var(--color-text);
  background: var(--color-section-bg);
}

.compare-table td {
  color: var(--color-text-muted);
}

.compare-table td::before {
  content: attr(data-label);
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.compare-col-gorod {
  background: var(--color-bg);
  border-left: 3px solid var(--color-primary);
}
.compare-table td.compare-col-gorod::before {
  color: var(--color-primary);
}

/* ---------- Contact form ---------- */

.contact-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.contact-intro {
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

.contact-form {
  background: var(--color-bg);
  border-radius: var(--radius-card);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

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

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  font-size: 0.792rem;
}

.form-required {
  color: #A32626;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: 0.88rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.2s ease;
}

.form-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  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 d='M2.5 4.5l3.5 3.5 3.5-3.5' fill='none' stroke='%231C2430' stroke-opacity='0.6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 12px 12px;
}

/* Kill the native arrow in Firefox (appearance:none alone leaves it there) */
.form-group select::-ms-expand {
  display: none;
}

.form-group select:invalid {
  color: var(--color-text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-group textarea {
  resize: vertical;
  min-height: 7rem;
}

.form-required-note {
  font-size: 0.792rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.form-submit-btn {
  width: 100%;
}

.form-privacy-note {
  font-size: 0.792rem;
  color: var(--color-text-muted);
  margin-top: 0.9rem;
}

.form-privacy-note a {
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--color-primary);
}

.form-message {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.836rem;
}

.form-message[hidden] {
  display: none;
}

.form-message--success {
  background: #EAF6EC;
  color: #1E6B33;
  border: 1px solid #BFE3C6;
}

.form-message--error {
  background: #FBEAEA;
  color: #A32626;
  border: 1px solid #F1C3C3;
}

/* ---------- Legal pages (privacy policy, etc.) ---------- */

.legal-content {
  max-width: 720px;
  margin: 0 auto;
}

.legal-content h1 {
  margin-bottom: 0.5rem;
}

.legal-updated {
  color: var(--color-text-muted);
  font-size: 0.836rem;
  margin-bottom: 2rem;
}

.legal-content h2 {
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.legal-content p {
  margin-bottom: 1rem;
}

.legal-content ul {
  list-style: disc;
  margin: 0 0 1rem 1.25rem;
}

.legal-content ul li {
  margin-bottom: 0.4rem;
}

.legal-contact {
  line-height: 1.6;
}

/* ---------- Footer ---------- */

.site-footer {
  background: var(--color-text);
  color: #C3CAD3;
  padding: 40px 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 24px;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
}

.footer-logo {
  width: var(--footer-logo-size);
  height: var(--footer-logo-size);
  flex-shrink: 0;
}

.footer-brand-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: var(--footer-brand-name-size);
  color: var(--color-bg);
}

.footer-tagline {
  max-width: 34rem;
  font-size: var(--footer-body-size);
  line-height: 1.4;
  margin: 0 0 0.3rem;
}

.footer-founded {
  font-size: var(--footer-body-size);
  margin: 0;
}

.footer-col-contact p {
  font-size: var(--footer-body-size);
  line-height: 1.5;
  margin: 0 0 0.2rem;
}
.footer-col-contact p:last-child {
  margin-bottom: 0;
}

.footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: var(--footer-legal-size);
}

.footer-legal-text {
  /* Explicit, not inherited: <p> is matched directly by the base.css
     `p { font-size: ... }` rule, which otherwise wins over the size
     inherited from .footer-bottom regardless of that ancestor's own
     specificity — same trap as the old .footer-meta/.footer-legal bug. */
  font-size: var(--footer-legal-size);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.65);
  margin: 0;
}

.footer-privacy-link {
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
}
.footer-privacy-link:hover,
.footer-privacy-link:focus-visible {
  color: var(--color-bg);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ================= Tablet ================= */
@media (min-width: 768px) {
  :root {
    --section-padding-y: 72px;
    --footer-body-size: 15px;
    --footer-legal-size: 13px;
    --footer-brand-name-size: 1.2rem;
    --footer-logo-size: 32px;
  }

  .card-grid--6 {
    grid-template-columns: repeat(2, 1fr);
  }
  .steps {
    grid-template-columns: repeat(3, 1fr);
  }
  .who-list {
    grid-template-columns: repeat(3, 1fr);
  }
  .who-item {
    border-top: none;
    border-left: 1px solid var(--color-border);
    padding: 0 2rem;
  }
  .who-item:first-child {
    border-left: none;
    padding-left: 0;
  }
  .why-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem 2.5rem;
  }
  .contact-inner {
    grid-template-columns: 1fr;
    max-width: 40rem;
    margin: 0 auto;
  }
  .site-footer {
    padding: 1.75rem 0;
  }
  .footer-grid {
    grid-template-columns: 1.6fr 1fr;
    gap: 1.25rem;
  }
  .footer-col-contact p {
    line-height: 1.3;
  }
  .footer-bottom {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin-top: 1.6rem;
    padding-top: 1rem;
  }

  /* Comparison table becomes a real table again */
  .compare-table {
    display: table;
    width: 100%;
  }
  .compare-table thead,
  .compare-table tbody {
    display: table-row-group;
  }
  .compare-table thead {
    display: table-header-group;
  }
  .compare-table tr {
    display: table-row;
    width: auto;
  }
  .compare-table th,
  .compare-table td {
    display: table-cell;
    width: auto;
  }
  .compare-table tbody tr {
    margin-bottom: 0;
    border: none;
    border-radius: 0;
  }
  .compare-table th,
  .compare-table td {
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--color-border);
  }
  .compare-table thead th {
    font-weight: 700;
    border-bottom: 2px solid var(--color-border);
  }
  .compare-table tbody th {
    background: none;
    white-space: nowrap;
  }
  .compare-table td::before {
    display: none;
  }
  .compare-col-gorod {
    border-left: 1.5px solid var(--color-primary);
    border-right: 1.5px solid var(--color-primary);
  }
  .compare-table thead .compare-col-gorod {
    color: var(--color-primary);
    border-top: 1.5px solid var(--color-primary);
  }
  .compare-table tbody tr:last-child .compare-col-gorod {
    border-bottom: 1.5px solid var(--color-primary);
  }
}

/* ================= Desktop ================= */
@media (min-width: 1024px) {
  :root {
    --section-padding-y: 96px;
  }

  .card-grid--6 {
    grid-template-columns: repeat(3, 1fr);
  }

  .why-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 32px 48px;
  }
}
