/* components.css — the parts kit: keys, blocks, chips, fields, logo, nav, theme toggle, seam. */

/* ---------- Keys (buttons) ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  min-block-size: 3rem;
  padding: var(--space-2xs) var(--space-m);
  border: 2px solid transparent;
  border-radius: var(--radius-s);
  font-family: var(--font-display);
  font-size: var(--step-0);
  font-weight: var(--fw-label);
  font-stretch: var(--wdth-label);
  letter-spacing: var(--tracking-label);
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--dur-micro) var(--ease-snap),
    box-shadow var(--dur-micro) var(--ease-snap),
    background-color var(--dur-micro) var(--ease-out);
}

/* A key sits on a 3px ledge; pressing seats it and the ledge collapses. */
.btn:active {
  transform: translateY(var(--ledge));
  box-shadow: 0 0 0 transparent;
}

.btn--primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 var(--ledge) 0 var(--signal-cyan);
}

.btn--primary:hover {
  background: color-mix(in srgb, var(--ink) 92%, var(--graphite));
  color: var(--paper);
}

.btn--secondary {
  background: var(--color-surface);
  border-color: var(--ink);
  color: var(--ink);
  box-shadow: 0 var(--ledge) 0 var(--graphite);
}

.btn--secondary:hover {
  background: var(--color-surface-raised);
  color: var(--ink);
}

.btn--ghost {
  color: var(--ink);
  background: transparent;
  text-decoration: underline;
  text-decoration-color: var(--graphite);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.btn--ghost:hover {
  text-decoration-color: var(--signal-magenta);
  text-decoration-thickness: 2px;
}

.btn--ghost:active {
  transform: none;
}

.btn--on-dark {
  background: transparent;
  border-color: var(--ink-plate-text);
  color: var(--ink-plate-text);
  box-shadow: 0 var(--ledge) 0 var(--signal-cyan);
}

.btn--on-dark:hover {
  background: color-mix(in srgb, var(--ink-plate-text) 10%, transparent);
  color: var(--ink-plate-text);
}

/* 40px key with a 44px hit area (the pseudo-element extends the target, not the look). */
.btn--sm {
  min-block-size: 2.5rem;
  padding: var(--space-3xs) var(--space-s);
  font-size: var(--step--1);
}

.btn--sm::before {
  content: "";
  position: absolute;
  inset-block: -2px;
  inset-inline: 0;
}

.btn--lg {
  min-block-size: 3.5rem;
  padding: var(--space-xs) var(--space-l);
  font-size: var(--step-1);
}

.btn--block {
  inline-size: 100%;
}

.btn__icon {
  inline-size: 1.1em;
  block-size: 1.1em;
  fill: currentcolor;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  background: transparent;
  border-color: var(--graphite);
  color: var(--graphite);
  opacity: 0.5;
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- Blocks (cards) ---------- */
/* Local token reset: a block always has a Block-face ground, even when it sits on an Ink plate. */
.card {
  --color-text: var(--ink);
  --color-text-muted: var(--graphite);
  --color-link: var(--ink);
  --color-focus: var(--signal-magenta);

  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-l);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--pegboard);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-s);
  transition:
    transform var(--dur-micro) var(--ease-snap),
    box-shadow var(--dur-micro) var(--ease-snap);
}

.card__media {
  margin: calc(var(--space-l) * -1) calc(var(--space-l) * -1) var(--space-xs);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: calc(var(--radius-m) - 1px) calc(var(--radius-m) - 1px) 0 0;
  background: var(--color-bg);
}

.card__media--square {
  aspect-ratio: 1;
}

.card__media img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

.card__icon {
  display: grid;
  place-items: center;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  color: var(--color-text);
}

.card__title {
  font-size: var(--step-2);
  font-weight: var(--fw-title);
  font-stretch: var(--wdth-label);
}

.card__text {
  color: var(--color-text-muted);
}

.card__footer {
  margin-block-start: auto;
  padding-block-start: var(--space-xs);
}

/* Stretched link: the whole card becomes the click target. */
.card__link {
  color: inherit;
  text-decoration: none;
}

.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card--interactive:hover,
.card--interactive:focus-within {
  transform: translateY(-2px);
  box-shadow: var(--shadow-m);
}

.card--flat {
  background: var(--color-bg);
  box-shadow: none;
}

/* Signal block: a 3px seam along its top edge. Once per page. */
.card--signal::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  block-size: var(--seam-w);
  background: var(--gradient-seam);
  border-radius: var(--radius-m) var(--radius-m) 0 0;
}

/* ---------- Badges and chips ---------- */
.badge,
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: var(--fw-label);
  font-stretch: var(--wdth-label);
  line-height: 1.4;
  background: var(--color-surface);
  color: var(--ink);
}

.badge {
  padding: 0.25em 0.6em;
}

.badge--brand {
  background: var(--signal-cyan);
  color: var(--color-on-brand);
}

.badge--neutral {
  background: var(--color-surface);
  border-color: var(--graphite);
  color: var(--graphite);
}

.badge--outline {
  background: transparent;
  border-color: var(--graphite);
  color: var(--ink);
}

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

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

.badge__icon {
  inline-size: 1em;
  block-size: 1em;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

/* Filter chip: a 44px key-like toggle. Pressed = cyan fill plus a drawn check, so it is not colour alone. */
.chip {
  min-block-size: 2.75rem;
  padding: 0 var(--space-s);
  border-color: var(--graphite);
  cursor: pointer;
  transition:
    transform var(--dur-micro) var(--ease-snap),
    background-color var(--dur-micro) var(--ease-out);
}

.chip:hover {
  border-color: var(--ink);
}

.badge[aria-pressed="true"],
.badge[aria-checked="true"],
.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  background: var(--signal-cyan);
  border-color: var(--ink);
  color: var(--color-on-brand);
}

.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  transform: translateY(1px);
}

.badge[aria-pressed="true"]::before,
.badge[aria-checked="true"]::before,
.chip[aria-pressed="true"]::before,
.chip[aria-checked="true"]::before {
  content: "";
  inline-size: 0.35em;
  block-size: 0.65em;
  margin-inline-end: 0.3em;
  margin-block-end: 0.15em;
  border: solid currentcolor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---------- Form fields ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.field__label {
  font-weight: var(--fw-semibold);
  color: var(--ink);
}

/* Required is a visible word, not an asterisk alone. */
.field--required .field__label::after {
  content: " (required)";
  font-weight: var(--fw-regular);
  color: var(--graphite);
}

.field__input {
  inline-size: 100%;
  min-block-size: 3rem;
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-s);
  background: var(--color-surface);
  color: var(--ink);
  font-size: var(--step-0);
  transition: border-color var(--dur-micro) var(--ease-out);
}

textarea.field__input {
  min-block-size: 8rem;
  resize: vertical;
}

.field__input:hover {
  border-color: var(--ink);
}

.field__input:focus-visible {
  border-color: var(--ink);
}

.field__input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  /* background-color, not the shorthand, so a disabled select keeps its chevron. */
  background-color: var(--color-bg);
}

/* Drawn chevron for every select, inset like the text on the left.
   currentcolor keeps it in step with the text in both themes and in forced colours. */
select.field__input {
  padding-inline-end: var(--space-xl);
  background-image:
    linear-gradient(45deg, transparent 50%, currentcolor 50%),
    linear-gradient(135deg, currentcolor 50%, transparent 50%);
  background-position:
    calc(100% - var(--space-s) - 0.3125rem) 50%,
    calc(100% - var(--space-s)) 50%;
  background-size: 0.3125rem 0.3125rem;
  background-repeat: no-repeat;
  appearance: none;
  text-overflow: ellipsis;
}

/* Forced colours: give the native control (and its own arrow) back. */
@media (forced-colors: active) {
  select.field__input {
    appearance: auto;
    background-image: none;
  }
}

.field__hint {
  font-size: var(--step--1);
  color: var(--color-text-muted);
}

.field__error {
  display: none;
  align-items: center;
  gap: var(--space-3xs);
  font-size: var(--step--1);
  font-weight: var(--fw-semibold);
  color: var(--color-error);
}

.field__error::before,
.form-status--success::before,
.form-status--error::before {
  content: "!";
  display: inline-grid;
  place-items: center;
  flex: none;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  border: 2px solid currentcolor;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: var(--fw-black);
  line-height: 1;
}

.form-status--success::before {
  content: "\2713";
}

.field--invalid .field__error {
  display: flex;
}

.field--invalid .field__input,
.field__input[aria-invalid="true"] {
  border-color: var(--color-error);
  border-width: 2px;
}

.checkbox,
.radio {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-block-size: 2.75rem;
  cursor: pointer;
}

.checkbox input,
.radio input {
  appearance: none;
  flex: none;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin: 0;
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-s);
  background: var(--color-surface);
  cursor: pointer;
}

.radio input {
  border-radius: 50%;
}

.checkbox input:hover,
.radio input:hover {
  border-color: var(--ink);
}

/* Checked: cyan fill plus an Ink mark (the mark colour is fixed because the fill is fixed). */
.checkbox input:checked {
  background: var(--signal-cyan)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23172033' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E")
    center / 100% no-repeat;
  border-color: var(--ink);
}

.radio input:checked {
  background: radial-gradient(circle, #172033 0 38%, var(--signal-cyan) 42%);
  border-color: var(--ink);
}

.checkbox input:disabled,
.radio input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-status--success,
.form-status--error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-s);
  background: var(--color-surface);
  border: 1px solid var(--pegboard);
  border-inline-start-width: 4px;
  border-radius: var(--radius-s);
  font-weight: var(--fw-semibold);
}

.form-status--success {
  color: var(--color-success);
  border-inline-start-color: var(--color-success);
}

.form-status--error {
  color: var(--color-error);
  border-inline-start-color: var(--color-error);
}

/* ---------- Logo ---------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-block-size: 2.75rem;
  color: var(--ink);
  text-decoration: none;
}

.logo__mark {
  flex: none;
  inline-size: auto;
  block-size: 2rem;
}

.site-footer .logo__mark {
  block-size: 2.5rem;
}

.logo__wordmark {
  display: flex;
  flex-direction: column;
  font-size: var(--step-1);
  line-height: 1;
}

.logo__line1 {
  font-family: var(--font-display);
  font-weight: var(--fw-black);
  font-stretch: var(--wdth-normal);
}

.logo__line2 {
  margin-block-start: 0.25em;
  font-family: var(--font-display);
  font-size: 0.62em;
  font-weight: var(--fw-label);
  font-stretch: var(--wdth-xwide);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* In a footer/ink plate the logo follows the plate text. */
.site-footer .logo {
  color: var(--ink-plate-text);
}

/* ---------- Navigation ---------- */
.site-nav__link {
  position: relative;
  display: flex;
  align-items: center;
  min-block-size: 3.5rem;
  padding-inline: var(--space-m);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: var(--fw-label);
  font-stretch: var(--wdth-label);
  letter-spacing: var(--tracking-label);
  text-decoration: none;
}

/* Inset ring: the joined list clips overflow, so an outside ring would be cut off. */
.site-nav__link:focus-visible {
  outline-offset: -3px;
}

.site-nav__link:hover {
  text-decoration: underline;
  text-decoration-color: currentcolor;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

/* Current page: an Ink peg seated under the link (cyan on Paper is only ~2.3:1; owner chose Ink 2026-11-14). Weight never changes, so nothing shifts. */
.site-nav__link::after {
  content: "";
  position: absolute;
  inset-inline-start: var(--space-m);
  inset-block-end: 0.5rem;
  inline-size: 2.5rem;
  block-size: 3px;
  background: var(--color-text);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-micro) var(--ease-snap);
}

.site-nav__link[aria-current="page"]::after {
  transform: scaleX(1);
}

@media (min-width: 1024px) {
  .site-nav__link {
    min-block-size: 2.75rem;
    padding-inline: 0;
  }

  .site-nav__link:focus-visible {
    outline-offset: 2px;
  }

  .site-nav__link::after {
    inset-inline: 0;
    inset-block-end: 0.25rem;
    inline-size: auto;
  }
}

.site-nav__actions .btn {
  inline-size: 100%;
}

@media (min-width: 1024px) {
  .site-nav__actions .btn {
    inline-size: auto;
  }
}

/* Menu button: visible word plus bars that form an X when open. */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-inline-size: 2.75rem;
  min-block-size: 2.75rem;
  padding: 0 var(--space-xs);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: var(--fw-label);
  font-stretch: var(--wdth-label);
}

.nav-toggle__bars {
  display: grid;
  gap: 5px;
}

.nav-toggle__bar {
  display: block;
  inline-size: 1.25rem;
  block-size: 2px;
  border-radius: 2px;
  background: currentcolor;
  transition:
    transform var(--dur-fast) var(--ease-out),
    opacity var(--dur-micro) var(--ease-out);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (min-width: 1024px) {
  .nav-toggle {
    display: none;
  }
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--space-xs);
  flex: none;
  min-inline-size: 2.75rem;
  min-block-size: 2.75rem;
  padding: 0 var(--space-s) 0 var(--space-xs);
  border: 1px solid var(--graphite);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: var(--fw-label);
  font-stretch: var(--wdth-label);
  transition: background-color var(--dur-micro) var(--ease-out);
}

.theme-toggle:hover {
  background: var(--color-surface);
}

.theme-toggle__icons {
  position: relative;
  flex: none;
  inline-size: 1.25rem;
  block-size: 1.25rem;
}

.theme-toggle__icon {
  position: absolute;
  inset: 0;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  transition:
    transform var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
}

/* Light: sun shown. Dark (aria-pressed="true"): moon shown. */
.theme-toggle__icon--moon {
  opacity: 0;
  transform: rotate(-90deg);
}

.theme-toggle[aria-pressed="true"] .theme-toggle__icon--sun {
  opacity: 0;
  transform: rotate(90deg);
}

.theme-toggle[aria-pressed="true"] .theme-toggle__icon--moon {
  opacity: 1;
  transform: rotate(0);
}

@media (min-width: 1024px) {
  .theme-toggle {
    align-self: auto;
    justify-content: center;
    padding: 0;
  }

  .theme-toggle__label {
    display: none;
  }
}

/* ---------- Seam ---------- */
/* The only gradient. Counts against the seam budget in DESIGN 1.2. */
.seam {
  block-size: var(--seam-w);
  border: 0;
  border-radius: 2px;
  background: var(--gradient-seam);
}

.icon {
  inline-size: 1em;
  block-size: 1em;
  fill: currentcolor;
  flex: none;
}
