/*
 * PIYAVE Labs — components
 * Brand Guidelines section 13 (specification) and section 25 (state matrix).
 * Sizes, radii, spacing and colours below are normative — these are built
 * exactly, not approximately.
 *
 * Two rules govern everything here:
 *   - Radius nesting: a child's radius is the parent's minus 2px, floored at 0.
 *     A 6px card contains 4px controls; a 10px dialog contains 6px cards.
 *   - Hover never moves anything. Colour and border change; geometry does not.
 */

/* ==== Buttons ============================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2); /* icon-to-label gap is always 8 */
  height: 40px;
  padding-inline: var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm); /* never circular, never a pill */
  font-family: var(--font-body);
  font-size: 0.9375rem; /* 15 */
  font-weight: var(--weight-medium);
  line-height: 1;
  letter-spacing: 0.005em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-colors);
}

.btn--sm { height: 32px; padding-inline: var(--space-3); font-size: var(--text-sm); }
.btn--lg {
  height: 48px;
  padding-inline: var(--space-5);
  font-size: var(--text-base);
  font-family: var(--font-display);
  font-weight: var(--weight-medium);
}

/* Primary — one per view. No shadow, ever. */
.btn--primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }
.btn--primary:active { background: var(--accent-active); border-color: var(--accent-active); }

/* Secondary — any number. */
.btn--secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--bg-subtle); border-color: var(--neutral-400); color: var(--text); }
.btn--secondary:active { background: var(--neutral-100); }

/* Inverse — for light sections needing a second heavy action, and on blue. */
.btn--inverse {
  background: var(--neutral-950);
  color: #fff;
  border-color: var(--neutral-950);
}
.btn--inverse:hover { background: var(--neutral-900); border-color: var(--neutral-900); color: #fff; }

/* On a Navy band the secondary action is a ghost against white type. */
.is-inverted .btn--secondary,
.section--navy .btn--secondary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: transparent;
}
.is-inverted .btn--secondary:hover,
.section--navy .btn--secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

/* Ghost / link — tertiary and inline actions only. */
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  padding-inline: 0;
  height: auto;
}
.btn--ghost:hover { color: var(--accent-hover); }

.btn[disabled], .btn[aria-disabled='true'] {
  opacity: var(--opacity-disabled);
  cursor: default;
  pointer-events: none;
}

/* Full width only on mobile and inside cards. */
@media (max-width: 639px) {
  .btn--block-mobile { width: 100%; }
}

/* A text link that reads as an action without being a button. */
.link-action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9375rem;
  font-weight: var(--weight-medium);
  color: var(--accent);
  text-decoration: none;
}
.link-action::after {
  content: '';
  width: 14px; height: 1px;
  background: currentColor;
  transition: width var(--duration-fast) var(--ease-standard);
}
.link-action:hover::after { width: 22px; }

/* ==== Cards =============================================================== */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  /* Cards at rest have a border, not a shadow. Depth is earned by interaction. */
  box-shadow: none;
  transition:
    border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}
@media (max-width: 639px) { .card { padding: var(--space-5); } }

a.card, .card--linked { text-decoration: none; color: inherit; }
a.card:hover, .card--linked:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  /* The card does not move. */
}

.card--quiet { background: var(--bg-subtle); }

/* Feature card — 40px padding, 24px blue icon, H4 title, Body-SM. */
.card--feature { padding: var(--space-10); }
@media (max-width: 639px) { .card--feature { padding: var(--space-6); } }

.card__icon {
  width: 24px; height: 24px;
  color: var(--accent);
  margin-bottom: var(--space-5);
  flex: none;
}
.card__title { margin-bottom: var(--space-3); }
.card__body {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: var(--space-5);
}
.card__foot { margin-top: auto; }

/* Case-study card — image sits flush to the top edge inside a 6px card. */
.card--case { padding: 0; overflow: hidden; }
.card--case .card__media { aspect-ratio: 16 / 9; background: var(--neutral-100); }
.card--case .card__media img { width: 100%; height: 100%; object-fit: cover; }
.card--case .card__inner { padding: var(--space-6); display: flex; flex-direction: column; flex: 1; }
.card--case .card__title {
  /* Title clamped to 2 lines. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card--case .card__metric {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* The optional blue accent bar that grows on hover — 24px to 48px, 180ms. */
.card--accent::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 24px; height: 2px;
  background: var(--accent);
  transition: width var(--duration-base) var(--ease-standard);
}
a.card--accent:hover::before { width: 48px; }

/* ==== Stat figures ======================================================== */

.stat__figure {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: var(--text-3xl);
  line-height: 1;
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat__label {
  display: block;
  margin-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}
@media (min-width: 640px) { .stat__figure { font-size: 2.5rem; } }
@media (min-width: 1024px) { .stat__figure { font-size: var(--text-4xl); } }
@media (min-width: 1440px) { .stat__figure { font-size: 3.5rem; } }

/* ==== Badges ============================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 20px;
  padding-inline: var(--space-2);
  border-radius: var(--radius-xs); /* never a pill */
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
}
.badge--neutral { border: 1px solid var(--border-strong); color: var(--text-secondary); }
.badge--accent { background: var(--accent-subtle); color: var(--blue-700); }
.badge--navy { background: var(--neutral-950); color: #fff; }

/* ==== Forms =============================================================== */

.field { display: block; margin-bottom: var(--space-5); }
.fieldset { border: 0; padding: 0; margin: 0 0 var(--space-8); }
.fieldset > legend {
  padding: 0;
  margin-bottom: var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

/* Labels are always visible above the field. Never a placeholder-as-label,
 * never a floating label. */
.field__label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--neutral-900);
}
.is-inverted .field__label { color: var(--text); }

.field__optional {
  margin-left: var(--space-2);
  font-weight: var(--weight-regular);
  color: var(--text-tertiary);
}

.input, .select, .textarea {
  display: block;
  width: 100%;
  height: 44px;
  padding: 10px var(--space-3);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  /* 16px prevents iOS zoom on focus. */
  font-size: var(--text-base);
  line-height: 1.4;
  transition: var(--transition-colors), box-shadow var(--duration-fast) var(--ease-standard);
}
.textarea { height: auto; min-height: 120px; resize: vertical; padding-block: var(--space-3); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--neutral-400); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.input[disabled], .textarea[disabled], .select[disabled] {
  background: var(--bg-subtle);
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
}

.select {
  appearance: none;
  padding-right: var(--space-10);
  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='%23667384' stroke-width='1.5' stroke-linecap='butt'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

/* Helper and error share reserved space so the layout never shifts. */
.field__helper, .field__error {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  line-height: 1.5;
  min-height: 1.5em;
}
.field__helper { color: var(--text-tertiary); }
.field__error { color: var(--error); font-weight: var(--weight-medium); }

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea { border-color: var(--error); }

/* Checkbox — 18px box, radius 2, whole row clickable. */
.checkbox { display: flex; gap: var(--space-2); align-items: flex-start; cursor: pointer; }
.checkbox input {
  appearance: none;
  flex: none;
  width: 18px; height: 18px;
  margin: 3px 0 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  cursor: pointer;
  transition: var(--transition-colors);
}
.checkbox input:hover { border-color: var(--accent); }
.checkbox input:checked {
  background: var(--accent);
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='butt'%3E%3Cpath d='m5 12 5 5 9-9'/%3E%3C/svg%3E");
  background-size: 14px;
  background-position: center;
  background-repeat: no-repeat;
}
.checkbox span { font-size: 0.9375rem; line-height: 1.5; }

/* Form layout: single column, 20px between fields, 32px between groups.
 * Primary action bottom-left, aligned to the fields. */
.form { max-width: 560px; }
.form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
}
.form__note { font-size: var(--text-sm); color: var(--text-tertiary); }

/* Honeypot — present for bots, invisible and unreachable for people. */
.hp-field {
  position: absolute !important;
  left: -9999px;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* ==== Alerts ============================================================== */

.alert {
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-left: 2px solid var(--text-tertiary);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  line-height: 1.55;
}
.alert strong { display: block; margin-bottom: var(--space-1); }
.alert--success { border-left-color: var(--success); background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bg); }
.alert--error { border-left-color: var(--error); background: var(--error-bg); color: var(--error-fg); border-color: var(--error-bg); }
.alert--info { border-left-color: var(--info); background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bg); }

/* ==== Ticked list ========================================================= */

.tick-list { display: grid; gap: var(--space-3); }
.tick-list li {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: var(--space-2);
  align-items: start;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-secondary);
}
.tick-list li::before {
  content: '';
  width: 20px; height: 20px;
  margin-top: 2px;
  background: currentColor;
  color: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='butt'%3E%3Cpath d='m5 12 5 5 9-9'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.5' stroke-linecap='butt'%3E%3Cpath d='m5 12 5 5 9-9'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ==== Accordion =========================================================== */

.accordion { border-top: 1px solid var(--border); }
.accordion__item { border-bottom: 1px solid var(--border); }
.accordion__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-5) 0;
  background: none;
  border: 0;
  text-align: left;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition-colors);
}
.accordion__trigger:hover { color: var(--accent); }
.accordion__icon {
  flex: none;
  width: 20px; height: 20px;
  transition: transform var(--duration-base) var(--ease-standard);
}
.accordion__trigger[aria-expanded='true'] .accordion__icon { transform: rotate(180deg); }
.accordion__panel { padding-bottom: var(--space-5); }
.accordion__panel p {
  max-width: 68ch;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--text-secondary);
}
.accordion__panel[hidden] { display: none; }

/* ==== Table =============================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: left;
  white-space: nowrap;
}
.table td {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border); /* row rules only, never zebra striping */
}
.table td.is-numeric,
.table th.is-numeric {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.table tbody tr:hover { background: var(--bg-subtle); }

/* ==== Breadcrumb ========================================================== */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.breadcrumb a { color: var(--text-tertiary); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb li { display: flex; gap: var(--space-2); }
.breadcrumb li + li::before { content: '/'; color: var(--border-strong); }
.breadcrumb [aria-current] { color: var(--neutral-900); }

/* ==== Pagination ========================================================== */

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-12);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px; height: 32px;
  padding-inline: var(--space-2);
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.pagination .page-numbers:hover { color: var(--accent); }
.pagination .page-numbers.current {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ==== Empty state ========================================================= */

.empty-state {
  padding: var(--space-12) var(--space-6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  text-align: center;
}
.empty-state__icon { width: 32px; height: 32px; margin: 0 auto var(--space-4); color: var(--neutral-400); }
.empty-state p { margin: var(--space-2) 0 var(--space-5); font-size: var(--text-sm); color: var(--text-secondary); }

/* ==== Figure / diagram ==================================================== */

.figure { margin: var(--space-10) 0; }
.figure img, .figure svg {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-none); /* figures are always square */
}
.figure figcaption {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
