/* TACO components: buttons, form fields, notices. Needs tokens.css first. Class names are prefixed
   with t- so they can sit next to admin or WordPress styles without clashing. */

.t-root, .t-root *, .t-root *::before, .t-root *::after { box-sizing: border-box; }
.t-root {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.t-display { font-family: var(--font-headline); font-weight: var(--weight-headline); line-height: var(--leading-tight); letter-spacing: -0.01em; }
.t-hand { font-family: var(--font-hand); }
.t-muted { color: var(--color-text-muted); }
.t-link { color: var(--color-primary-text); text-decoration: underline; text-underline-offset: 0.15em; text-decoration-thickness: 1px; }
.t-link:hover { color: var(--color-primary-text-hover); text-decoration-thickness: 2px; }

/* Focus: one visible ring everywhere, keyboard only */
.t-root :focus { outline: none; }
.t-root :focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-sm);
}

.t-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;
}

/* Buttons */
.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-height); padding: 0 var(--space-6);
  border: 0; border-radius: var(--radius-pill);
  font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--text-md); line-height: 1;
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.t-btn:focus-visible { border-radius: var(--radius-pill); }
.t-btn:active { transform: translateY(1px); }
.t-btn[disabled], .t-btn[aria-disabled="true"] { cursor: progress; opacity: 0.75; transform: none; }
.t-btn svg { width: 1.25em; height: 1.25em; flex: none; }

/* The one call to action on a page */
.t-btn--action { background: var(--color-action); color: var(--color-on-action); min-height: var(--control-height-lg); }
.t-btn--action:hover { background: var(--color-action-hover); }
.t-btn--block { display: flex; width: 100%; }

/* Quiet, inline actions ("Add another child", "Remove") */
.t-btn--text {
  background: none; color: var(--color-primary-text); padding: 0 var(--space-2); margin-left: calc(-1 * var(--space-2));
  font-family: var(--font-body); font-weight: var(--weight-semibold); font-size: var(--text-sm);
  min-height: 2.75rem; border-radius: var(--radius-sm);
}
.t-btn--text:hover { color: var(--color-primary-text-hover); text-decoration: underline; text-underline-offset: 0.2em; }

/* Fields */
.t-field { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.t-label { font-weight: var(--weight-medium); font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--color-text); }
.t-label .t-optional { font-weight: var(--weight-regular); color: var(--color-text-muted); }
.t-hint { font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--color-text-muted); margin: 0; }
.t-error {
  display: flex; gap: var(--space-2); align-items: flex-start; margin: 0;
  font-size: var(--text-sm); line-height: var(--leading-snug); font-weight: var(--weight-medium); color: var(--color-error);
}
.t-error::before {
  content: "!"; flex: none; display: inline-grid; place-items: center; width: 1.125rem; height: 1.125rem; margin-top: 0.1rem;
  border-radius: 50%; background: var(--color-error); color: var(--white); font-size: 0.75rem; font-weight: 700; line-height: 1;
}

.t-input, .t-select {
  display: block; width: 100%; min-height: var(--control-height); margin: 0;
  padding: 0 var(--control-padding-x);
  font: inherit; font-size: var(--text-base); color: var(--color-text);
  background-color: var(--color-surface);
  border: var(--control-border-width) solid var(--color-border-control); border-radius: var(--radius-md);
  -webkit-appearance: none; appearance: none;
  transition: border-color var(--duration-fast) var(--ease);
}
.t-input::placeholder { color: var(--grey-500); opacity: 1; }
.t-input:hover, .t-select:hover { border-color: var(--ink-700); }
.t-input:focus-visible, .t-select:focus-visible, .t-input:focus, .t-select:focus {
  outline: var(--focus-ring-width) solid var(--color-focus); outline-offset: 0; border-color: var(--color-focus); border-radius: var(--radius-md);
}
.t-input[aria-invalid="true"], .t-select[aria-invalid="true"] { border-color: var(--color-error); }
.t-select {
  padding-right: 2.5rem; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%231F2A2E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1.125rem;
}
.t-select:invalid { color: var(--grey-500); } /* placeholder option shown */
.t-select option { color: var(--color-text); }

/* Checkbox with a large hit area: the whole row is the label */
.t-check {
  display: grid; grid-template-columns: 1.5rem 1fr; gap: var(--space-3); align-items: start;
  padding: var(--space-3) 0; cursor: pointer; font-size: var(--text-sm); line-height: var(--leading-snug);
}
.t-check input {
  -webkit-appearance: none; appearance: none; margin: 0; width: 1.5rem; height: 1.5rem; cursor: pointer;
  border: var(--control-border-width) solid var(--color-border-control); border-radius: var(--radius-sm); background: var(--color-surface);
  display: grid; place-items: center; transition: background-color var(--duration-fast) var(--ease);
}
.t-check input::after {
  content: ""; width: 0.45rem; height: 0.8rem; margin-top: -0.15rem;
  border: solid var(--white); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) scale(0);
  transition: transform var(--duration-fast) var(--ease);
}
.t-check input:checked { background: var(--color-primary-text); border-color: var(--color-primary-text); }
.t-check input:checked::after { transform: rotate(45deg) scale(1); }
.t-check input:focus-visible { outline: var(--focus-ring-width) solid var(--color-focus); outline-offset: var(--focus-ring-offset); }
.t-check input[aria-invalid="true"] { border-color: var(--color-error); }

/* Notices */
.t-notice {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--text-sm); line-height: var(--leading-snug); font-weight: var(--weight-medium);
}
.t-notice--error { background: var(--color-error-bg); color: var(--color-error); }
.t-notice:focus { outline: none; }

/* Card */
.t-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-1); }
/* A <legend> is not a flex item of its fieldset, so .t-field's gap skips it; match the gap explicitly. */
fieldset.t-field > legend { margin-bottom: var(--space-2); }
