/* ==========================================================================
   Components. Every interactive component defines default, hover,
   focus-visible (global, base.css), active, disabled, loading and error states.
   ========================================================================== */

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

.btn {
  --btn-bg: var(--color-brand);
  --btn-fg: #fff;
  --btn-border: var(--btn-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  min-height: 44px;
  padding: var(--space-12) var(--space-24);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--text-small);
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--duration-instant) var(--ease),
    border-color var(--duration-instant) var(--ease),
    color var(--duration-instant) var(--ease),
    transform var(--duration-instant) var(--ease);
}

.btn:hover { --btn-bg: var(--color-brand-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Loading: label hidden, spinner shown, clicks ignored. */
.btn[aria-busy="true"] {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 20px;
  height: 20px;
  margin: auto;
  border: 2px solid var(--btn-fg);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn--secondary { --btn-bg: transparent; --btn-fg: var(--color-text); --btn-border: var(--color-border-control); }
.btn--secondary:hover { --btn-bg: var(--color-surface-subtle); --btn-border: var(--color-text); }

.btn--inverse { --btn-bg: #fff; --btn-fg: #000; }
.btn--inverse:hover { --btn-bg: var(--color-surface-tint); }

.btn--outline-inverse { --btn-bg: transparent; --btn-fg: #fff; --btn-border: rgb(255 255 255 / 0.65); }
.btn--outline-inverse:hover { --btn-bg: rgb(255 255 255 / 0.14); --btn-border: #fff; }

.btn--lg {
  min-height: 52px;
  padding-inline: var(--space-32);
  font-size: var(--text-body);
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.link-arrow:hover { text-decoration: underline; }
.link-arrow svg { transition: transform var(--duration-fast) var(--ease); }
.link-arrow:hover svg { transform: translateX(3px); }

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

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration-fast) var(--ease);
}

.card:has(.card__link):hover { border-color: var(--color-border-strong); }

.card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-12);
  padding: var(--space-24);
}

.card__title {
  font-size: var(--text-heading-sm);
  line-height: var(--leading-snug);
  letter-spacing: -0.01em;
}

.card__text {
  color: var(--color-text-soft);
  font-size: var(--text-small);
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--text-caption);
}

.card__byline {
  margin-top: auto;
  color: var(--color-text-muted);
  font-size: var(--text-caption);
}

/* One link per card; its ::after stretches over the card so the whole card is the click target. */
.card__link {
  color: inherit;
  text-decoration: none;
}

.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card__link:hover { color: var(--color-brand); }
.card__link:focus-visible { outline: none; }
.card__link:focus-visible::after {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
  border-radius: var(--radius-control);
}

.card--service {
  gap: var(--space-12);
  padding: var(--space-24);
}

.card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-control);
  background: var(--color-surface-tint);
  color: var(--color-brand);
}

.card__action { margin-top: auto; padding-top: var(--space-8); }

.card__media {
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--color-surface-tint);
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-normal) var(--ease);
}

.card:hover .card__media img { transform: scale(1.03); }

.featured { margin-bottom: var(--space-24); }

@media (min-width: 64rem) {
  .card--featured { flex-direction: row; }
  .card--featured .card__media { flex: 0 0 50%; aspect-ratio: auto; min-height: 20rem; }
  .card--featured .card__body { justify-content: center; padding: var(--space-32); }
  .card--featured .card__title { font-size: var(--text-heading); letter-spacing: -0.02em; }
  .card--featured .card__text { font-size: var(--text-body-lg); }
}

.card--person .card__body { gap: var(--space-8); padding: var(--space-16); }
.card--person .card__title { font-size: var(--text-lead); }

@media (min-width: 48rem) {
  .card--person .card__body { padding: var(--space-24); }
  .card--person .card__title { font-size: var(--text-heading-sm); }
}

/* ---- Portraits ------------------------------------------------------------------------- */

.portrait {
  container-type: inline-size;
  --tone-bg: #eff6ff;
  --tone-fg: #3a5290;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 5;
  background: var(--tone-bg);
  color: var(--tone-fg);
}

.portrait__initials {
  font-size: clamp(var(--text-heading), 24cqi, var(--text-display));
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}

.portrait--tone-2 { --tone-bg: #dbeafe; --tone-fg: #1e40af; }
.portrait--tone-3 { --tone-bg: #e5e7eb; --tone-fg: #374151; }
.portrait--tone-4 { --tone-bg: #f3f4f6; --tone-fg: #4662ac; }
.portrait--tone-5 { --tone-bg: #e0e7ff; --tone-fg: #3730a3; }

.portrait--photo img { width: 100%; height: 100%; object-fit: cover; }

.portrait--profile {
  max-width: 18rem;
  overflow: hidden;
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card);
}

/* ---- Testimonials ----------------------------------------------------------------------- */

.quote-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-20);
  height: 100%;
  margin: 0;
  padding: var(--space-24);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}

.quote-card__text { margin: 0; }

.quote-card__text p {
  font-size: var(--text-lead);
  line-height: 1.45;
}

.quote-card__author {
  display: flex;
  flex-direction: column;
  margin-top: auto;
}

.quote-card__name { font-weight: 600; }
.quote-card__role { color: var(--text-soft); font-size: var(--text-small); }

/* ---- Badges, chips, tags ---------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-10);
  border-radius: var(--radius-pill);
  font-size: var(--text-caption);
  font-weight: 600;
  line-height: 1.5rem;
  white-space: nowrap;
}

.badge--brand { background: var(--color-surface-tint); color: var(--color-brand-strong); }
.badge--neutral { background: var(--color-surface-subtle); border: 1px solid var(--color-border); color: var(--color-text-soft); }

.chips { margin-bottom: var(--space-32); }

.chips__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  min-height: 44px;
  padding: 0 var(--space-16);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-small);
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--duration-instant) var(--ease), border-color var(--duration-instant) var(--ease), color var(--duration-instant) var(--ease);
}

.chip:hover { border-color: var(--color-text); background: var(--color-surface-subtle); }
.chip:active { transform: translateY(1px); }
.chip[aria-current="true"] { border-color: var(--color-text); background: var(--color-text); color: #fff; }
.chip__count { font-weight: 400; }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  margin: var(--space-32) 0 0;
  padding: 0;
  list-style: none;
}

.tag-list a { text-decoration: none; }
.tag-list a:hover .badge { border-color: var(--color-text); }

/* ---- Pagination -------------------------------------------------------------------------- */

.pagination { margin-top: var(--space-32); }

.pagination__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  margin: 0;
  padding: 0;
  list-style: none;
}

.pagination__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--space-12);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-size: var(--text-small);
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--duration-instant) var(--ease), border-color var(--duration-instant) var(--ease);
}

a.pagination__link:hover { border-color: var(--color-text); background: var(--color-surface-subtle); }
.pagination__link[aria-current="page"] { border-color: var(--color-text); background: var(--color-text); color: #fff; }
.pagination__link.is-disabled { border-color: var(--color-border); color: var(--color-text-muted); cursor: not-allowed; }
.pagination__gap { padding-inline: var(--space-8); color: var(--color-text-muted); }

/* ---- Prose (Markdown content) --------------------------------------------------------------- */

.prose { color: var(--color-text-soft); }
.prose > * + * { margin-top: var(--space-20); }

.prose p,
.prose li {
  font-size: var(--text-body-lg);
  line-height: 1.7;
}

.prose h2 { margin-top: var(--space-32); color: var(--color-text); font-size: var(--text-heading-sm); }
.prose h3 { margin-top: var(--space-24); color: var(--color-text); font-size: var(--text-lead); }
.prose > :first-child { margin-top: 0; }

.prose ul,
.prose ol { padding-left: var(--space-24); }

.prose li + li { margin-top: var(--space-8); }
.prose strong { color: var(--color-text); font-weight: 600; }
.prose a { color: var(--color-link); text-decoration: underline; }

.prose blockquote {
  margin-left: 0;
  padding-left: var(--space-20);
  border-left: 3px solid var(--color-brand);
  color: var(--color-text);
}

.prose code {
  padding: 0 0.25em;
  border-radius: 4px;
  background: var(--color-surface-subtle);
  font-size: 0.9em;
}

.prose hr { border: 0; border-top: 1px solid var(--color-border); }

/* ---- Alerts ------------------------------------------------------------------------------------ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-12);
  padding: var(--space-16);
  border: 1px solid;
  border-radius: var(--radius-control);
  font-size: var(--text-small);
}

.alert__icon { flex: none; margin-top: 2px; }
.alert__title { font-weight: 600; }
.alert__message { margin-top: 2px; }

.alert--info { background: var(--color-surface-tint); border-color: #bfdbfe; color: #1e3a8a; }
.alert--success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert--error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.surface-dark .alert--success { background: rgb(16 185 129 / 0.14); border-color: rgb(110 231 183 / 0.5); color: #a7f3d0; }
.surface-dark .alert--error { background: rgb(248 113 113 / 0.14); border-color: rgb(252 165 165 / 0.5); color: #fecaca; }

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

.form,
.form__grid {
  display: grid;
  gap: var(--space-20);
}

.form__grid { grid-template-columns: minmax(0, 1fr); }

@media (min-width: 40rem) {
  .form__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.field { display: grid; gap: var(--space-8); align-content: start; }
.field__label { font-size: var(--text-small); font-weight: 600; }
.field__optional { color: var(--text-muted); font-weight: 400; }
.field__hint { color: var(--text-muted); font-size: var(--text-caption); }
.field__error { color: var(--danger); font-size: var(--text-caption); font-weight: 500; }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: var(--space-12) var(--space-16);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-body);
  line-height: 1.5;
  transition: border-color var(--duration-instant) var(--ease), box-shadow var(--duration-instant) var(--ease);
}

.textarea { min-height: 9rem; resize: vertical; }
.input:hover,
.select:hover,
.textarea:hover { border-color: var(--color-text); }

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--color-danger);
  box-shadow: inset 0 0 0 1px var(--color-danger);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--color-surface-subtle);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.input::placeholder { color: var(--color-text-muted); opacity: 1; }

.select {
  padding-right: 2.5rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23101010' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-position: right var(--space-14) center;
  background-repeat: no-repeat;
}

.input--on-dark {
  border-color: rgb(255 255 255 / 0.55);
  background: rgb(255 255 255 / 0.08);
  color: #fff;
}

.input--on-dark::placeholder { color: #d1d5db; }
.input--on-dark:hover { border-color: #fff; }
.input--on-dark[aria-invalid="true"] { border-color: #fca5a5; box-shadow: inset 0 0 0 1px #fca5a5; }

.checkbox { display: flex; align-items: flex-start; gap: var(--space-12); }

.checkbox__input {
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--color-brand);
  cursor: pointer;
}

.checkbox__label { font-size: var(--text-small); cursor: pointer; }

/* Honeypot: present in the DOM for bots, invisible and unreachable for people. */
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.newsletter-form { display: grid; gap: var(--space-12); }

.newsletter-form__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
}

.newsletter-form__row .input { flex: 1 1 14rem; width: auto; }

.search { position: relative; display: flex; gap: var(--space-8); }

.search__icon {
  position: absolute;
  top: 50%;
  left: var(--space-16);
  display: inline-flex;
  color: var(--color-text-muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.search__input { flex: 1; padding-left: 3rem; }

/* ---- Loading, empty, error, not-found states ------------------------------------------------------- */

.skeleton {
  display: block;
  border-radius: var(--radius-control);
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 37%, #e5e7eb 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  from { background-position: 100% 50%; }
  to { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

.skeleton--media { aspect-ratio: 3 / 2; border-radius: 0; }
.skeleton--line { height: 16px; margin: var(--space-16) var(--space-24) 0; }
.skeleton--short { width: 50%; }
.skeleton--title { width: min(30rem, 70%); height: 48px; margin-bottom: var(--space-16); }
.skeleton--wide { width: min(40rem, 90%); height: 20px; margin-inline: 0; }
.skeleton-card { padding-bottom: var(--space-24); }

.state {
  display: grid;
  justify-items: center;
  gap: var(--space-12);
  max-width: 36rem;
  margin-inline: auto;
  padding-block: var(--space-32);
  text-align: center;
}

.state__icon { color: var(--color-brand); }
.state--error .state__icon { color: var(--color-danger); }
.state__code { color: var(--color-brand); font-size: var(--text-display); font-weight: 700; line-height: 1; }
.state__title { font-size: var(--text-heading); }
.state__text { color: var(--color-text-soft); }

.state__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-12);
  margin-top: var(--space-16);
}

.state--empty { padding-block: var(--space-64); }

/* ---- Long-content robustness ------------------------------------------------------------------
   Grid/flex children must be allowed to shrink, and very long words, URLs or translated strings
   must wrap instead of causing horizontal scroll. */

.detail__main,
.profile__main,
.split__text,
.split__media,
.contact__form,
.contact__aside,
.card__body,
.alert__body,
.page-header__text {
  min-width: 0;
}

main,
.site-footer {
  overflow-wrap: anywhere;
}

/* ---- Call-to-action band (used by every page via components/cta-band.js) -------------------------------------------------------------------- */

.cta-band { padding-block: var(--space-32); }

@media (min-width: 48rem) {
  .cta-band { padding-block: var(--space-64); }
}

.cta-band__inner {
  display: grid;
  gap: var(--space-24);
}

@media (min-width: 64rem) {
  .cta-band__inner { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-64); }
}

.cta-band__title { font-size: var(--text-heading); }

.cta-band__lead {
  max-width: 40rem;
  margin-top: var(--space-12);
  color: var(--text-soft);
  font-size: var(--text-lead);
}

.cta-band__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-12);
}

/* ---- Detail pages (shared by matters-detail and insights-article) ---------------------------------------------------------- */

.detail {
  display: grid;
  gap: var(--space-32);
}

@media (min-width: 64rem) {
  .detail {
    grid-template-columns: minmax(0, 1fr) 18rem;
    gap: var(--space-64);
    align-items: start;
  }

  .detail__aside { position: sticky; top: calc(var(--header-height) + var(--space-24)); }
}

.detail__figure { margin: 0 0 var(--space-32); }

.detail__image {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-card);
}

.detail__aside { display: grid; gap: var(--space-24); }

.facts {
  display: grid;
  gap: var(--space-16);
  margin: 0;
  padding: var(--space-20);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
}

.facts__item dt {
  color: var(--color-text-muted);
  font-size: var(--text-caption);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.facts__item dd {
  margin: var(--space-8) 0 0;
  font-weight: 500;
}

.gallery {
  display: grid;
  gap: var(--space-16);
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  margin-top: var(--space-32);
}

.gallery__item { margin: 0; }
.gallery__item img { width: 100%; border-radius: var(--radius-control); }
.gallery__item figcaption { margin-top: var(--space-8); color: var(--color-text-muted); font-size: var(--text-caption); }

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8) var(--space-20);
  color: var(--color-text-soft);
  font-size: var(--text-small);
}

.article-meta__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
}

.article__back { margin-top: var(--space-32); }
