/* ==========================================================================
   Resilience Group — Components
   Version 1.0

   Reusable UI components. All values from tokens.css.
   Must render correctly in both light and dark mode with zero overrides.
   ========================================================================== */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-interactive);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  color: var(--color-text-inverse);
  text-decoration: none;
}

.btn-accent {
  background: var(--color-accent);
  color: #ffffff;
}
.btn-accent:hover {
  background: var(--color-accent-hover);
  color: #ffffff;
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.btn-secondary:hover {
  background: var(--color-primary-highlight);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-muted);
}
.btn-ghost:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-interactive);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: var(--leading-display);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.card-body {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: var(--leading-body);
  margin-bottom: var(--space-4);
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-interactive);
}

.card-link:hover {
  color: var(--color-primary-hover);
  text-decoration: none;
}

.card-link::after {
  content: ' \2192';
}

/* Card with icon/label at top */
.card-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-uppercase);
  color: var(--color-accent);
  margin-bottom: var(--space-3);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-full);
}

.badge-default {
  background: var(--color-primary-highlight);
  color: var(--color-primary);
}

.badge-copper {
  background: var(--color-accent-highlight);
  color: var(--color-accent);
}

.badge-success {
  background: var(--color-success-highlight);
  color: var(--color-success);
}

.badge-error {
  background: var(--color-error-highlight);
  color: var(--color-error);
}

/* --------------------------------------------------------------------------
   Trust Bar
   -------------------------------------------------------------------------- */

.trust-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  background: var(--color-surface-offset);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
}

.trust-item {
  text-align: center;
  padding: 0 var(--space-2);
}

.trust-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-primary);
  line-height: var(--leading-display);
}

.trust-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: var(--leading-label);
  margin-top: var(--space-2);
}

@media (max-width: 767px) {
  .trust-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-6);
    padding: var(--space-6) var(--space-4);
  }
}

/* --------------------------------------------------------------------------
   FAQ Accordion
   -------------------------------------------------------------------------- */

.faq-list {
  list-style: none;
  padding: 0;
}

.faq-item {
  border-bottom: 1px solid var(--color-divider);
}

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-5) 0;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  transition: color var(--transition-interactive);
  min-height: 44px;
}

.faq-question:hover {
  color: var(--color-primary);
}

.faq-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-left: var(--space-4);
  transition: transform var(--transition-interactive);
  color: var(--color-text-faint);
}

.faq-item[open] .faq-icon {
  transform: rotate(45deg);
}

.faq-answer {
  padding: 0 0 var(--space-5) 0;
  color: var(--color-text-muted);
  font-size: var(--text-base);
  line-height: var(--leading-body);
}

.faq-answer p + p {
  margin-top: var(--space-3);
}

/* --------------------------------------------------------------------------
   Breadcrumbs
   -------------------------------------------------------------------------- */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  list-style: none;
  padding: 0;
}

.breadcrumbs li + li::before {
  content: '/';
  margin-right: var(--space-2);
  color: var(--color-text-faint);
}

.breadcrumbs a {
  color: var(--color-text-faint);
  text-decoration: none;
  transition: color var(--transition-interactive);
}

.breadcrumbs a:hover {
  color: var(--color-primary);
}

.breadcrumbs .current {
  color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Comparison Table
   -------------------------------------------------------------------------- */

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.comparison-table thead th {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: 500;
}

.comparison-table thead th:first-child {
  border-radius: var(--radius-md) 0 0 0;
}

.comparison-table thead th:last-child {
  border-radius: 0 var(--radius-md) 0 0;
}

.comparison-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}

.comparison-table tbody tr:nth-child(even) {
  background: var(--color-surface-offset);
}

/* Responsive table wrapper */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   Process Steps
   -------------------------------------------------------------------------- */

.process-steps {
  list-style: none;
  padding: 0;
}

.process-step {
  display: flex;
  gap: var(--space-4);
  padding-bottom: var(--space-8);
  position: relative;
}

.process-step:last-child {
  padding-bottom: 0;
}

.process-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 44px;
  bottom: 0;
  width: 2px;
  background: var(--color-divider);
}

.step-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
}

.step-title {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
}

.step-desc {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: var(--leading-body);
  margin-top: var(--space-1);
}

/* --------------------------------------------------------------------------
   Section Header (reusable pattern)
   -------------------------------------------------------------------------- */

.section-label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: var(--tracking-uppercase);
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-3);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: var(--leading-display);
  color: var(--color-text);
}

.section-desc {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: var(--leading-body);
  margin-top: var(--space-3);
  max-width: 72ch;
}

/* --------------------------------------------------------------------------
   CTA Block
   -------------------------------------------------------------------------- */

.cta-block {
  background: var(--color-surface-offset);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-8);
  text-align: center;
}

.cta-block .section-title {
  font-size: var(--text-2xl);
}

.cta-block .section-desc {
  margin-left: auto;
  margin-right: auto;
}

.cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: center;
  margin-top: var(--space-6);
}

/* --------------------------------------------------------------------------
   Differentiator Grid (Why Resilience)
   -------------------------------------------------------------------------- */

.diff-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}

.diff-item h3 {
  margin-bottom: var(--space-2);
}

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

@media (max-width: 767px) {
  .diff-grid {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   Author Card
   -------------------------------------------------------------------------- */

.author-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.author-img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.author-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.author-role {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Sprint H: Sticky mobile CTA
   Per docs/responsive-parametrisation.md §3.
   Label: "Speak to us" → /contact/. Hidden on tablet+ (header CTA suffices).
   Opt-in via .sticky-cta wrapper element added to layout (typically in
   _footer or per-page before </body>). Hidden when class .sticky-cta-off
   is present on <body> (e.g. /contact/ itself).
   -------------------------------------------------------------------------- */

.sticky-cta {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  z-index: var(--z-sticky-cta, 55);
  display: flex;
  justify-content: stretch;
  padding-block: var(--space-3);
  padding-block-end: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  padding-inline: var(--container-pad);
  background: color-mix(in oklch, var(--color-bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(150%) blur(8px);
  backdrop-filter: saturate(150%) blur(8px);
  border-block-start: 1px solid var(--color-divider);
  box-shadow: var(--shadow-md);
}

.sticky-cta__link {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--space-3) var(--space-5);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background var(--transition-interactive);
}

.sticky-cta__link:hover,
.sticky-cta__link:focus-visible {
  background: var(--color-primary-hover);
  color: var(--color-text-inverse);
  text-decoration: none;
}

/* Hide above tablet (header carries the Contact CTA from 768px up). */
@media (min-width: 768px) {
  .sticky-cta { display: none; }
}

/* Suppress when explicitly disabled (e.g. on /contact/ itself). */
body.sticky-cta-off .sticky-cta,
.sticky-cta[hidden] {
  display: none !important;
}

/* Add bottom padding to page-main so content isn't covered by the sticky CTA
   on mobile. ~64px = button + padding + safe-area baseline. */
@media (max-width: 767px) {
  body:not(.sticky-cta-off) .page-main {
    padding-bottom: calc(var(--space-16) + 24px);
  }
}

/* --------------------------------------------------------------------------
   Sprint H: Table strategies
   Per asym-intel-internal:ops/RESPONSIVE-PUBLISHING-KNOWHOW.md §7.
   Two opt-in classes — pick by content shape, not by default.
   -------------------------------------------------------------------------- */

/* 7a — Stacked cards: row-as-record (services, fees, team).
   Every <td> must carry data-label="…" for the mobile collapse to label rows. */
.table-stack {
  width: 100%;
  border-collapse: collapse;
}

.table-stack thead {
  background: var(--color-surface-offset);
}

.table-stack th,
.table-stack td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-sm);
}

.table-stack th {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-uppercase);
  color: var(--color-text-muted);
}

@media (max-width: 767px) {
  .table-stack thead {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  .table-stack tr {
    display: block;
    margin-block-end: var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
  }
  .table-stack td {
    display: block;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-divider);
  }
  .table-stack tr td:last-child {
    border-bottom: none;
  }
  .table-stack td::before {
    content: attr(data-label) ": ";
    display: inline-block;
    min-width: 10ch;
    font-weight: 600;
    color: var(--color-text-muted);
  }
}

/* 7b — Horizontal scroll: comparative (Cat 2 bands, jurisdiction comparison).
   Wrap any genuinely comparative table in:
   <div class="table-scroll" role="region" aria-label="…" tabindex="0">
     <table>…</table>
   </div>
*/
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
}

.table-scroll table {
  min-width: 640px;
  margin: 0;
  border-collapse: collapse;
}

.table-scroll th,
.table-scroll td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-divider);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.table-scroll th:first-child,
.table-scroll td:first-child {
  position: sticky;
  left: 0;
  background: var(--color-surface);
  box-shadow: 1px 0 0 var(--color-divider);
  white-space: normal;
}

.table-scroll thead th {
  background: var(--color-surface-offset);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-uppercase);
  color: var(--color-text-muted);
}

.table-scroll:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* Subtle hint that horizontal scroll exists on touch devices */
@media (max-width: 767px) {
  .table-scroll::after {
    content: "";
    display: block;
    height: 1px;
  }
  .table-scroll {
    position: relative;
  }
}

/* --------------------------------------------------------------------------
   Sprint H: Touch-target floor enforcement helpers
   Per VP-005. The site-header buttons and links already meet the floor;
   these utilities make it easy to mark new interactive elements as compliant.
   -------------------------------------------------------------------------- */

.tap-target {
  min-width: 44px;
  min-height: 44px;
}
