/*
 * Reusable components. Requires tokens.css and base.css.
 * Nothing here depends on the catalogue layout in catalogue.css.
 */

/* =========================================================
   Material: frosted surface
   ========================================================= */

.surface-frost {
  position: relative;
  isolation: isolate;
  background: var(--frost-fill);
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--frost-highlight), var(--frost-shadow);
  -webkit-backdrop-filter: blur(var(--frost-blur)) saturate(var(--frost-saturate));
  backdrop-filter: blur(var(--frost-blur)) saturate(var(--frost-saturate));
}

.surface-frost::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background-image: var(--grain);
  opacity: calc(var(--grain-opacity) * 0.8);
  mix-blend-mode: multiply;
  pointer-events: none;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .surface-frost { background: var(--frost-fill-strong); }
}

/* =========================================================
   Buttons: primary · secondary · quiet
   ========================================================= */

.button {
  --button-bg: transparent;
  --button-bg-hover: var(--button-bg);
  --button-fg: var(--text-primary);
  --button-border: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border: 1px solid var(--button-border);
  border-radius: var(--radius-sm);
  background: var(--button-bg);
  color: var(--button-fg);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: var(--weight-medium);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.button:hover { background: var(--button-bg-hover); }
.button:active { transform: translateY(1px); }

.button--primary {
  --button-bg: var(--color-ink-900);
  --button-bg-hover: #2c2f37;
  --button-fg: var(--color-paper-0);
  --button-border: var(--color-ink-900);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.12), 0 1px 2px rgb(27 29 34 / 0.16);
}

.button--secondary {
  --button-bg: var(--frost-fill-strong);
  --button-bg-hover: var(--color-white);
  --button-border: var(--color-line-strong);
  box-shadow: var(--frost-highlight);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.button--quiet {
  --button-bg-hover: rgb(27 29 34 / 0.05);
  padding: 0 var(--space-3);
}

.button--sm {
  min-height: var(--control-height-sm);
  padding: 0 var(--space-3);
  font-size: 0.875rem;
}

.button:disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button--primary:disabled,
.button--primary[aria-disabled="true"]:not([aria-busy="true"]) {
  --button-bg: var(--color-paper-2);
  --button-bg-hover: var(--color-paper-2);
  --button-border: var(--color-paper-2);
  --button-fg: var(--color-ink-500);
}

.button--secondary:disabled,
.button--secondary[aria-disabled="true"]:not([aria-busy="true"]),
.button--quiet:disabled,
.button--quiet[aria-disabled="true"]:not([aria-busy="true"]) {
  --button-bg-hover: var(--button-bg);
  --button-fg: var(--text-disabled);
}

.button__arrow {
  display: inline-block;
  transition: transform var(--duration-base) var(--ease-out);
}

.button:hover .button__arrow { transform: translateX(2px); }

/* Busy: the label keeps its width; a spinner replaces it visually. */
.button[aria-busy="true"] {
  cursor: progress;
  color: transparent;
}

.button[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1rem;
  height: 1rem;
  border: 1.5px solid var(--button-fg);
  border-right-color: transparent;
  border-radius: 50%;
  animation: ha-spin 700ms linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .button[aria-busy="true"]::after { animation-duration: 2.4s; }
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* =========================================================
   Form controls
   ========================================================= */

.field {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.field__label {
  font-size: var(--type-label-size);
  line-height: var(--type-label-line);
  font-weight: 500;
}

.field__optional {
  color: var(--text-meta);
  font-weight: 400;
}

.field__hint,
.field__error {
  font-size: var(--type-small-size);
  line-height: var(--type-small-line);
}

.field__hint { color: var(--text-meta); }

.field__error {
  display: none;
  color: var(--state-error-text);
}

.field[data-invalid="true"] .field__error { display: block; }
.field[data-invalid="true"] .field__hint { display: none; }

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  background-color: var(--frost-fill-strong);
  box-shadow: inset 0 1px 2px rgb(27 29 34 / 0.04);
  font-size: 1rem; /* 16px prevents zoom on iOS focus */
  line-height: 1.4;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.textarea {
  min-height: 5.5rem;
  padding: var(--space-3);
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder { color: var(--color-ink-300); }

.input:hover,
.select:hover,
.textarea:hover { border-color: rgb(27 29 34 / 0.28); }

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--color-electric);
  box-shadow: 0 0 0 3px rgb(46 91 255 / 0.18);
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--state-error);
  background-color: rgb(255 255 255 / 0.92);
}

.input[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 3px rgb(228 100 75 / 0.22); }

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

.input--mono {
  font-family: var(--font-mono);
  letter-spacing: normal;
  font-size: 0.9375rem;
}

.select {
  appearance: none;
  padding-right: 2.5rem;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--color-ink-700) 50%),
    linear-gradient(135deg, var(--color-ink-700) 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* Checkbox and radio */
.choice-group {
  display: grid;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.choice-group > legend {
  padding: 0;
  margin-bottom: var(--space-1);
}

.choice {
  display: grid;
  grid-template-columns: 1.125rem 1fr;
  align-items: start;
  column-gap: var(--space-3);
  min-height: var(--control-height-sm);
  padding-block: var(--space-2);
  cursor: pointer;
}

.choice__input {
  appearance: none;
  display: grid;
  place-content: center;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0.125rem 0 0;
  border: 1px solid rgb(27 29 34 / 0.34);
  border-radius: 5px;
  background: var(--color-white);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

.choice__input[type="radio"] { border-radius: 50%; }

.choice__input::before {
  content: "";
  width: 0.625rem;
  height: 0.625rem;
  background: var(--color-paper-0);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 9%, 37% 72%);
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease-out);
}

.choice__input[type="radio"]::before {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  clip-path: none;
}

.choice__input:checked {
  background: var(--color-ink-900);
  border-color: var(--color-ink-900);
}

.choice__input:checked::before { transform: scale(1); }

.choice__input:disabled {
  background: var(--surface-recessed);
  border-color: var(--color-line-strong);
  cursor: not-allowed;
}

.choice__text { display: grid; gap: 2px; min-width: 0; }
.choice__title { font-size: 1rem; line-height: 1.4; }
.choice__hint { font-size: var(--type-small-size); line-height: 1.45; color: var(--text-meta); }
.choice__hint code { font-size: 0.75rem; }

/* Switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--control-height-sm);
  cursor: pointer;
}

.switch__input {
  appearance: none;
  position: relative;
  flex: none;
  width: 2.5rem;
  height: 1.5rem;
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--color-paper-2);
  box-shadow: inset 0 0 0 1px var(--color-line-strong);
  cursor: pointer;
  transition: background-color var(--duration-base) var(--ease-out);
}

.switch__input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: var(--color-white);
  box-shadow: 0 1px 2px rgb(27 29 34 / 0.22);
  transition: transform var(--duration-base) var(--ease-out);
}

.switch__input:checked {
  background: var(--color-electric);
  box-shadow: none;
}

.switch__input:checked::before { transform: translateX(1rem); }

.switch__text { font-size: 1rem; line-height: 1.4; }

/* =========================================================
   Status chips: connected · pending · error · trust
   Neutral chip; only the marker carries colour, and each state
   has a distinct marker shape so meaning survives without colour.
   ========================================================= */

.status {
  --status-marker: var(--color-ink-300);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 1.625rem;
  padding: 0 var(--space-3) 0 var(--space-2);
  border: var(--border-hairline);
  border-radius: var(--radius-pill);
  background: var(--frost-fill-strong);
  box-shadow: var(--frost-highlight);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  letter-spacing: normal;
  font-size: var(--type-meta-size);
  line-height: 1;
  white-space: nowrap;
}

.status::before {
  content: "";
  flex: none;
  width: 0.4375rem;
  height: 0.4375rem;
  margin-left: 2px;
  border-radius: 50%;
  background: var(--status-marker);
}

/* Connected: solid dot */
.status[data-state="connected"] { --status-marker: var(--state-connected); }

/* Pending: open ring, slowly rotating */
.status[data-state="pending"] { --status-marker: transparent; }

.status[data-state="pending"]::before {
  width: 0.5rem;
  height: 0.5rem;
  border: 1.5px solid var(--color-ink-500);
  border-right-color: transparent;
  animation: ha-spin 1.2s linear infinite;
}

/* Error: small diamond */
.status[data-state="error"] { --status-marker: var(--state-error); }

.status[data-state="error"]::before {
  border-radius: 1px;
  transform: rotate(45deg);
}

/* Trust: check in ink */
.status[data-state="trust"] { --status-marker: var(--state-trust); }

.status[data-state="trust"]::before {
  width: 0.5625rem;
  height: 0.4375rem;
  border-radius: 0;
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 9%, 37% 72%);
}

@media (prefers-reduced-motion: reduce) {
  .status[data-state="pending"]::before {
    animation: none;
    border-style: dotted;
    border-right-color: var(--color-ink-500);
  }
}

/* =========================================================
   Information hierarchy
   Every card orders its content in the same six levels, and
   skips the ones it does not need:

   1 Context   .card__header   what kind of thing, when, state   mono 12
   2 Identity  .entity         who or what it is about            sans 14–15 / 500
   3 Message   .card__title    the one thing to understand        sans 17 or 20 / 500
   4 Detail    .card__text     at most two sentences              sans 14 / Ink 700
   5 Evidence  .facts, .meta-row, .disclosure  identifiers        mono 12
   6 Action    .card__footer   at most one primary action

   Limits per card: one title, one status, three text sizes,
   one primary action. Identifiers never appear in titles.
   ========================================================= */

/* =========================================================
   Entity: media + name + meta + optional trailing slot
   ========================================================= */

.entity {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.entity__media {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: var(--color-white);
  box-shadow: inset 0 0 0 1px var(--color-line), 0 1px 2px rgb(27 29 34 / 0.05);
}

.entity__media > img {
  width: 1.25rem;
  height: 1.25rem;
}

.entity__text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.entity__name {
  overflow: hidden;
  font-size: 1rem;
  font-weight: var(--weight-strong);
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity__meta {
  overflow: hidden;
  font-family: var(--font-mono);
  letter-spacing: normal;
  font-size: var(--type-meta-size);
  line-height: var(--type-meta-line);
  color: var(--text-meta);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity__trailing {
  flex: none;
  margin-left: auto;
}

/* A vertical list of entities, separated by hairlines. */
.entity-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entity-list > li { padding: var(--space-3) 0; }
.entity-list > li:first-child { padding-top: 0; }
.entity-list > li:last-child { padding-bottom: 0; }
.entity-list > li + li { border-top: var(--border-hairline); }

/* Small: inline attribution in footers and sentences. */
.entity--sm { gap: var(--space-2); }

.entity--sm .entity__media {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 6px;
}

.entity--sm .entity__media > img {
  width: 0.8125rem;
  height: 0.8125rem;
}

.entity--sm .entity__name {
  font-size: var(--type-small-size);
}

/* Overlapping media for a group of entities. */
.entity-stack {
  display: flex;
  flex: none;
}

.entity-stack > .entity__media {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 7px;
  box-shadow: 0 0 0 2px var(--color-paper-0), inset 0 0 0 1px var(--color-line);
}

.entity-stack > .entity__media + .entity__media { margin-left: -0.375rem; }

.entity-stack > .entity__media > img {
  width: 0.875rem;
  height: 0.875rem;
}

.entity-stack__more {
  display: grid;
  place-items: center;
  min-width: 1.75rem;
  height: 1.75rem;
  margin-left: -0.375rem;
  padding: 0 0.3125rem;
  border-radius: 7px;
  background: var(--color-paper-1);
  box-shadow: 0 0 0 2px var(--color-paper-0), inset 0 0 0 1px var(--color-line);
  font-family: var(--font-mono);
  letter-spacing: normal;
  font-size: 0.6875rem;
  color: var(--text-secondary);
}

/* =========================================================
   Option list: a single choice between entities, inside a card.
   Native radios; rows are separated by space, not borders.
   ========================================================= */

.option-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 3.25rem;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.option:hover { background: rgb(27 29 34 / 0.035); }

.option__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option > .entity { flex: 1; }

.option__indicator {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--color-line-strong);
  transition: box-shadow var(--duration-fast) var(--ease-out);
}

.option:has(.option__input:checked) {
  background: var(--color-white);
  box-shadow: inset 0 0 0 1px var(--color-line), 0 1px 2px rgb(27 29 34 / 0.05);
}

.option:has(.option__input:checked) .option__indicator {
  box-shadow: inset 0 0 0 5px var(--color-ink-900);
}

.option:has(.option__input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.option__placeholder {
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  letter-spacing: normal;
  font-size: 0.75rem;
  color: var(--text-meta);
}

/* =========================================================
   Card: fixed slots, one frosted surface
   ========================================================= */

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
  padding: var(--space-5);
}

.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  min-height: 1.625rem;
}

.card__main {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.card__title {
  font-family: var(--font-sans);
  font-size: var(--type-title-card-size);
  font-weight: 500;
  line-height: var(--type-title-line);
  letter-spacing: var(--type-title-track);
  text-wrap: balance;
}

.card--dialog .card__title { font-size: var(--type-title-dialog-size); }

.card__text {
  font-size: var(--type-ui-size);
  line-height: var(--type-ui-line);
  color: var(--text-secondary);
  text-wrap: pretty;
}

.card__text--clamp {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 2.25rem;
  margin-top: auto; /* footers align across cards of different length */
  padding-top: var(--space-4);
  border-top: var(--border-hairline);
}

.card__footer > .entity { flex: 0 1 auto; }
.card__footer > :not(.entity) { flex: none; }
.card__footer > .card__note { flex: 1 1 auto; }

.card__note {
  display: flex;
  gap: var(--space-3);
  font-size: var(--type-small-size);
  line-height: var(--type-small-line);
  color: var(--text-secondary);
}

.card__note > .t-meta { flex: none; padding-top: 1px; }

/* =========================================================
   Evidence: meta row, facts, disclosure
   ========================================================= */

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  font-family: var(--font-mono);
  letter-spacing: normal;
  font-size: var(--type-meta-size);
  line-height: var(--type-meta-line);
  color: var(--text-meta);
}

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-2) var(--space-5);
  margin: 0;
}

.facts > dt {
  font-family: var(--font-mono);
  letter-spacing: normal;
  font-size: var(--type-meta-size);
  line-height: 1.6;
  color: var(--text-meta);
}

.facts > dd {
  min-width: 0;
  font-size: var(--type-small-size);
  line-height: var(--type-small-line);
  overflow-wrap: anywhere;
}

.facts > dd code { font-size: var(--type-meta-size); }

.disclosure {
  border-top: var(--border-hairline);
}

.disclosure__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 2.5rem;
  padding-top: var(--space-2);
  font-size: var(--type-small-size);
  color: var(--text-meta);
  list-style: none;
  cursor: pointer;
}

.disclosure__summary::-webkit-details-marker { display: none; }

.disclosure__summary::after {
  content: "";
  width: 0.4375rem;
  height: 0.4375rem;
  margin-right: 2px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--duration-base) var(--ease-out);
}

.disclosure[open] > .disclosure__summary::after { transform: translateY(1px) rotate(225deg); }
.disclosure__summary:hover { color: var(--text-primary); }

.disclosure__body { padding: var(--space-2) 0 var(--space-1); }

/* =========================================================
   Permission list: what a grant allows, in plain language
   ========================================================= */

.permissions {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.permission {
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr);
  align-items: baseline;
  gap: var(--space-3);
  font-size: var(--type-ui-size);
  line-height: var(--type-ui-line);
}

.permission::before {
  content: "";
  width: 0.625rem;
  height: 0.5rem;
  transform: translateY(-1px);
  background: var(--color-ink-900);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 9%, 37% 72%);
}

.permission[data-kind="deny"] { color: var(--text-meta); }

.permission[data-kind="deny"]::before {
  height: 1px;
  transform: translateY(-4px);
  background: var(--color-ink-300);
  clip-path: none;
}

/* =========================================================
   Notices: compact card
   ========================================================= */

.notice {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5) var(--space-5);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--frost-fill-strong);
  box-shadow: var(--frost-highlight);
}

.notice__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.notice__title { font-size: 1rem; font-weight: var(--weight-strong); line-height: 1.4; }
.notice__body { font-size: var(--type-small-size); line-height: var(--type-small-line); color: var(--text-secondary); }
.notice__body code { font-size: 0.75rem; overflow-wrap: anywhere; }

/* =========================================================
   Provider / model identity tokens
   Third-party marks from style-guide/shared/assets/logos/,
   referenced as <img> so they also load from file://.
   Never used as Hey Aira branding.
   ========================================================= */

/*
 * Colour policy for marks from shared/assets/logos/:
 * - use the brand's colour file (*-color.svg) when the brand has one;
 * - brands whose mark is monochrome (OpenAI, xAI, Anthropic) use the
 *   monochrome file, softened so it never reads as heavy black;
 * - unavailable or disabled entities show every mark in greyscale.
 */
img[src*="/logos/"]:not([src$="-color.svg"]) { opacity: 0.78; }

.provider[aria-pressed="true"] img[src*="/logos/"],
.option:has(.option__input:checked) img[src*="/logos/"] { opacity: 1; }

.provider-mark {
  flex: none;
  display: block;
  width: var(--provider-mark-size, 1.25rem);
  height: var(--provider-mark-size, 1.25rem);
}

.provider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  min-height: 3.25rem;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--frost-fill);
  box-shadow: var(--frost-highlight);
  color: var(--text-primary);
  text-align: left;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.provider > .entity { flex: 1; }
.provider .entity__media { width: 2.25rem; height: 2.25rem; border-radius: 9px; }
.provider .entity__name { font-size: var(--type-ui-size); }

/* Chip form for inline use in sentences. */
.provider--chip {
  --provider-mark-size: 0.875rem;
  display: inline-flex;
  gap: var(--space-2);
  max-width: 100%;
  min-height: 1.75rem;
  padding: 0 var(--space-3) 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--frost-fill-strong);
  font-size: var(--type-small-size);
  font-weight: 500;
  white-space: nowrap;
  vertical-align: middle;
}

.provider--chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Selectable form. */
button.provider {
  width: 100%;
  font: inherit;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out);
}

button.provider:hover {
  border-color: var(--color-line-strong);
  background: var(--frost-fill-strong);
}

.provider[aria-pressed="true"] {
  border-color: var(--color-ink-900);
  background: var(--color-white);
  box-shadow: inset 0 0 0 1px var(--color-ink-900);
}

.provider__check {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--color-line-strong);
}

.provider[aria-pressed="true"] .provider__check {
  background: var(--color-ink-900);
  box-shadow: none;
  -webkit-mask: radial-gradient(circle, transparent 0 2.5px, #000 3px);
  mask: radial-gradient(circle, transparent 0 2.5px, #000 3px);
}

button.provider:disabled {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  cursor: not-allowed;
}

button.provider:disabled .entity__name { color: var(--text-meta); }
button.provider:disabled .entity__media > img { opacity: 0.4; filter: grayscale(1); }

/* =========================================================
   Segmented control (native radios)
   ========================================================= */

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  min-width: 0;
  margin: 0;
  padding: 3px;
  border: var(--border-hairline);
  border-radius: 10px;
  background: rgb(235 230 222 / 0.6);
}

.segmented__option { position: relative; }

.segmented__input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented__label {
  display: grid;
  place-items: center;
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  border-radius: 7px;
  font-family: var(--font-mono);
  letter-spacing: normal;
  font-size: var(--type-meta-size);
  color: var(--text-meta);
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.segmented__input:hover + .segmented__label { color: var(--text-primary); }

.segmented__input:checked + .segmented__label {
  background: var(--color-white);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgb(27 29 34 / 0.1), inset 0 0 0 1px var(--color-line);
}

.segmented__input:focus-visible + .segmented__label {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* =========================================================
   OAuth / MCP authorization card
   A .card.card--dialog. Root data-state:
   request | authorizing | connected | error.
   Children with data-when="…" render only in the listed states.

   Order: context (Hey Aira, state) → client entity → one question
   → what it allows → technical details (collapsed) → two actions.
   ========================================================= */

.auth-card {
  width: 100%;
  max-width: 23.5rem;
  gap: var(--space-5);
  container-type: inline-size;
  container-name: auth-card;
}

.auth-card[data-state="request"] [data-when]:not([data-when~="request"]),
.auth-card[data-state="authorizing"] [data-when]:not([data-when~="authorizing"]),
.auth-card[data-state="connected"] [data-when]:not([data-when~="connected"]),
.auth-card[data-state="error"] [data-when]:not([data-when~="error"]) {
  display: none;
}

.auth-card__decision {
  display: grid;
  gap: var(--space-4);
}

.auth-card__body {
  display: grid;
  gap: var(--space-3);
}

/* Two equal actions at the end of a dialog card. */
.card__actions,
.auth-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.auth-card[data-state="authorizing"] .entity__media {
  animation: ha-breathe 1.6s var(--ease-out) infinite alternate;
}

@keyframes ha-breathe {
  to { box-shadow: inset 0 0 0 1px var(--color-line), 0 0 0 4px rgb(27 29 34 / 0.05); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card[data-state="authorizing"] .entity__media { animation: none; }
}

/* Narrow card: primary action first, full width. */
@container auth-card (max-width: 19rem) {
  .auth-card__actions { grid-template-columns: minmax(0, 1fr); }
  .auth-card__actions > .button--primary { order: -1; }
}

/* =========================================================
   Site footer
   A full section, not a line: one statement, three link groups,
   and a quiet base row with the Hey Aira name.
   ========================================================= */

.site-footer {
  margin-top: var(--space-8);
  border-top: var(--border-hairline);
}

.site-footer__inner {
  display: grid;
  gap: var(--space-8);
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: var(--space-8) var(--layout-gutter) var(--space-6);
}

.site-footer__lead {
  display: grid;
  justify-items: start;
  gap: var(--space-4);
}

.site-footer__statement {
  max-width: 18ch;
  font-family: var(--font-serif);
  font-size: var(--type-h2-size);
  font-weight: 400;
  line-height: var(--type-h2-line);
  letter-spacing: var(--type-h2-track);
  text-wrap: balance;
}

.site-footer__groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: var(--space-6) var(--space-7);
}

.site-footer__title {
  margin-bottom: var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--type-ui-size);
  font-weight: var(--weight-strong);
  line-height: 1.4;
  letter-spacing: var(--type-text-track);
}

.site-footer__links {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__links a {
  display: inline-block;
  padding: 2px 0;
  color: var(--text-secondary);
  font-size: var(--type-ui-size);
  line-height: 1.45;
  text-decoration: none;
}

.site-footer__links a:hover {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.site-footer__base {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
  padding-top: var(--space-5);
  border-top: var(--border-hairline);
}

.site-footer__legal {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-meta);
}

@media (min-width: 60rem) {
  .site-footer { margin-top: var(--space-9); }

  .site-footer__inner {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    column-gap: var(--space-8);
    padding-top: var(--space-9);
  }

  .site-footer__base { grid-column: 1 / -1; }
}

/* =========================================================
   Toast
   ========================================================= */

.toast {
  position: fixed;
  bottom: max(var(--space-5), env(safe-area-inset-bottom));
  left: 50%;
  z-index: 50;
  max-width: calc(100vw - 2rem);
  overflow: hidden;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--color-ink-900);
  color: var(--color-paper-0);
  box-shadow: 0 10px 30px -12px rgb(27 29 34 / 0.45);
  font-family: var(--font-mono);
  letter-spacing: normal;
  font-size: var(--type-meta-size);
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.75rem);
  transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* =========================================================
   Page patterns
   Reusable sections for product pages. They use the type roles
   from base.css unchanged and add no cards around content.
   ========================================================= */

/* ---------- Logo row: the tools a product works with ---------- */

.logo-row {
  display: grid;
  justify-items: center;
  gap: var(--space-5);
  text-align: center;
}

.logo-row__title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--type-small-size);
  font-weight: var(--weight-regular);
  line-height: var(--type-small-line);
  letter-spacing: var(--type-text-track);
  color: var(--text-meta);
}

.logo-row__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
  gap: var(--space-5) var(--space-2);
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.logo-row__item {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
}

.logo-row__item img {
  width: 2.25rem;
  height: 2.25rem;
}

/* Monochrome brand marks are softened so they never read as heavy black. */
.logo-row__item img[data-mono] { opacity: 0.8; }

.logo-row__name {
  font-size: var(--type-small-size);
  line-height: 1.3;
  color: var(--text-secondary);
}

@media (max-width: 29.99rem) {
  .logo-row__list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Flow: steps in order, joined by one line ---------- */

.flow {
  --flow-node: 0.75rem;
  --flow-gap: var(--space-6);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: var(--flow-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow__step {
  position: relative;
  display: grid;
  align-content: start;
  gap: var(--space-2);
  padding-top: var(--space-6);
}

/* Node */
.flow__step::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: var(--flow-node);
  height: var(--flow-node);
  border-radius: 50%;
  background: var(--surface-canvas);
  box-shadow: inset 0 0 0 1.5px var(--color-ink-700);
}

/* The last step ends in the brand dot. */
.flow__step:last-child::before {
  background: var(--brand-dot-color);
  box-shadow: none;
}

/* Line to the next node */
.flow__step::after {
  content: "";
  position: absolute;
  top: calc(var(--flow-node) / 2);
  left: calc(var(--flow-node) + var(--space-2));
  right: calc(var(--flow-gap) * -1 + var(--space-2));
  height: 1px;
  background: var(--color-line-strong);
}

.flow__step:last-child::after { display: none; }

.flow__text {
  margin: 0;
  font-size: var(--type-ui-size);
  line-height: var(--type-ui-line);
  color: var(--text-secondary);
}

@media (max-width: 47.99rem) {
  .flow { grid-template-columns: minmax(0, 1fr); --flow-gap: var(--space-5); }
  .flow__step { padding: 0 0 0 var(--space-6); }
  .flow__step::before { top: 0.35rem; }
  .flow__step::after {
    top: calc(0.35rem + var(--flow-node) + var(--space-2));
    bottom: calc(var(--flow-gap) * -1 + var(--space-2));
    left: calc(var(--flow-node) / 2);
    right: auto;
    width: 1px;
    height: auto;
  }
}

/* ---------- Layer stack: what lives where, top to bottom ---------- */

.layer-stack {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: var(--border-strong);
}

.layer-stack__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--space-2) var(--space-5);
  padding: var(--space-5) 0;
  border-bottom: var(--border-hairline);
}

.layer-stack__what {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--type-h3-size);
  font-weight: var(--weight-medium);
  line-height: var(--type-h3-line);
  letter-spacing: var(--type-h3-track);
}

.layer-stack__where {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-small-size);
  color: var(--text-meta);
  white-space: nowrap;
}

.layer-stack__row--own .layer-stack__where { color: var(--text-primary); }

@media (max-width: 29.99rem) {
  .layer-stack__row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Changelog: released, in progress, planned ---------- */

.changelog {
  display: grid;
  gap: var(--space-6);
}

.changelog__group {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: var(--space-3) var(--space-5);
}

.changelog__label { align-self: start; justify-self: start; }

.changelog__list {
  --changelog-line: var(--color-line-strong);
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--changelog-line);
}

.changelog__group[data-state="planned"] .changelog__list {
  border-left-style: dashed;
}

.changelog__item {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 0 0 var(--space-4) var(--space-5);
}

.changelog__item:last-child { padding-bottom: 0; }

/* Marker on the line; shape follows the status chip markers. */
.changelog__item::before {
  content: "";
  position: absolute;
  top: 0.45rem;
  left: -0.3125rem;
  width: 0.5625rem;
  height: 0.5625rem;
  border-radius: 50%;
  background: var(--surface-canvas);
  box-shadow: inset 0 0 0 1.5px var(--color-ink-300);
}

.changelog__group[data-state="released"] .changelog__item::before {
  background: var(--state-connected);
  box-shadow: 0 0 0 3px var(--surface-canvas);
}

.changelog__group[data-state="progress"] .changelog__item::before {
  box-shadow: inset 0 0 0 1.5px var(--color-ink-500);
}

.changelog__title {
  font-size: var(--type-ui-size);
  font-weight: var(--weight-strong);
  line-height: 1.45;
}

.changelog__group[data-state="planned"] .changelog__title {
  font-weight: var(--weight-regular);
  color: var(--text-secondary);
}

.changelog__meta {
  font-family: var(--font-mono);
  font-size: var(--type-meta-size);
  line-height: var(--type-meta-line);
  letter-spacing: normal;
  color: var(--text-meta);
  overflow-wrap: anywhere;
}

@media (max-width: 47.99rem) {
  .changelog__group { grid-template-columns: minmax(0, 1fr); }
}
