/* ==========================================================================
   Base styles and reusable components
   Buttons, links, tags and status labels share the same hover, focus,
   disabled and active states everywhere.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html.nav-locked, html.nav-locked body { overflow: hidden; }

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 650;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 16px; top: -48px;
  z-index: 200;
  padding: 8px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}
.skip-link:focus-visible { top: 12px; }

.icon { flex: none; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn[hidden] { display: none; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: var(--radius-sm); }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15.5px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }

.btn-secondary { background: #fff; color: var(--ink); border-color: var(--border-input); }
.btn-secondary:hover { background: var(--bg-subtle); }
.btn-secondary:active { background: var(--bg-hover); }

.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--bg-subtle); }
.btn-ghost:active { background: var(--bg-hover); }

.btn-on-dark { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.32); }
.btn-on-dark:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.5); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9A1F15; }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--accent);
}
.link-arrow .icon { transition: transform var(--t-fast) var(--ease); }
.link-arrow:hover { text-decoration: none; }
.link-arrow:hover .icon { transform: translateX(2px); }

/* ---------- Tags and status labels ---------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.tag-muted { background: var(--bg-hover); color: var(--muted); }
.tag-flagged { background: var(--status-flagged-label); color: var(--status-flagged-text); }
.tag-followup { background: var(--status-followup-label); color: var(--status-followup-text); }
.tag-unread { background: var(--status-unread-label); color: var(--status-unread-text); }
.tag-pinned { background: transparent; color: var(--status-pinned-text); padding: 0 2px; }
.tag-optout { background: var(--bg-hover); color: var(--muted); }
.tag-success { background: var(--success-soft); color: var(--success); }
.tag-accent { background: var(--accent-soft); color: var(--accent); }

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* ---------- Forms ---------- */

.field { display: grid; gap: 6px; }
.field + .field, .field-row + .field, .field + .field-row { margin-top: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row .field + .field { margin-top: 0; }
@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; gap: 18px; }
}

.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.label { font-size: 14px; font-weight: 600; color: var(--ink); }
.label-link { font-size: 13.5px; font-weight: 600; }

.input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
textarea.input { height: auto; min-height: 96px; padding: 10px 13px; line-height: 1.5; resize: vertical; }
/* Honeypot field for the lead forms: off-screen, never focusable. */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.input::placeholder { color: #8A93A3; }
.input:hover { border-color: #B4BCC8; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.16); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.14); }
.input:disabled { background: var(--bg-subtle); color: var(--label); cursor: not-allowed; }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 72px; }
.input-action {
  position: absolute;
  top: 50%; right: 6px;
  transform: translateY(-50%);
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.input-action:hover { background: var(--blue-soft); }

.field-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--danger);
}
.field-error .icon { flex: none; margin-top: 1px; }
.field-error[hidden] { display: none; }
.field-hint { font-size: 13px; color: var(--muted); }

/* Alerts */
.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 14px;
  line-height: 1.5;
}
.alert .icon { flex: none; margin-top: 1px; }
.alert strong { display: block; font-weight: 650; }
.alert[hidden] { display: none; }
.alert-link { display: inline-block; margin-top: 6px; font-weight: 600; }
.alert-error { background: #FEF3F2; border-color: #FBD5D0; color: #7A271A; }
.alert-error .icon { color: var(--danger); }
.alert-info { background: var(--blue-soft); border-color: #CCDAF5; color: #1E3A8A; }
.alert-success { background: var(--success-soft); border-color: #B7E4C7; color: #05603A; }

/* Loading spinner inside buttons */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-loading { cursor: progress; opacity: 0.9; }

/* ---------- Section scaffolding ---------- */

.section { padding: 96px 0; }
.section-head { max-width: 640px; margin-bottom: 48px; }
.section-head h2 { font-size: clamp(1.75rem, 2.6vw, 2.25rem); }
.section-head p { margin-top: 14px; font-size: 17px; color: var(--muted); }

@media (max-width: 760px) {
  .section { padding: 64px 0; }
  .section-head { margin-bottom: 32px; }
}
