/* layercell design system — forms, data, and state
   Load AFTER layercell.css. Hosted pages and internal tools both use this.

   Everything here obeys the same rules as the rest of the system:
     · Signal marks state, focus and links. Never a fill, never a heading.
     · Depth is layer offset + opacity. No shadow, no scrim.
     · Adjacent surfaces share one hairline.
     · 44px hit floor on anything a merchant touches.
*/

/* ── Field ─────────────────────────────────────────────────────────
   Label, control, one line of help. Help text is not optional — a bare
   input with no help is an unanswered question. */

.lc-field {
  display: flex;
  flex-direction: column;
  gap: var(--lc-space-2);
  min-width: 0;
}

.lc-field__label {
  font-size: var(--lc-body-s);
  font-weight: 500;
  color: var(--lc-text);
  display: flex;
  align-items: baseline;
  gap: var(--lc-space-2);
}
.lc-field__optional {
  font-family: var(--lc-font-mono);
  font-size: 11px;
  color: var(--lc-text-faint);
  font-weight: 400;
}
.lc-field__help {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--lc-text-dim);
}
.lc-field__error {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--lc-signal);
  display: flex;
  gap: var(--lc-space-2);
}
.lc-field__error::before {
  content: '!';
  font-family: var(--lc-font-mono);
  font-weight: 500;
}

.lc-fields {
  display: flex;
  flex-direction: column;
  gap: var(--lc-space-6);
}

/* ── Text inputs, selects, textareas ───────────────────────────────
   One border, one radius, one focus treatment across every control type. */

.lc-input,
.lc-select,
.lc-textarea {
  font-family: var(--lc-font-sans);
  font-size: var(--lc-action);
  line-height: 1.4;
  color: var(--lc-text);
  background: var(--lc-ink-raised);
  border: var(--lc-rule-width) solid var(--lc-rule-strong);
  border-radius: var(--lc-radius-action);
  padding: var(--lc-space-3) var(--lc-space-4);
  min-height: var(--lc-hit-min);
  width: 100%;
  min-width: 0;
  transition: border-color var(--lc-transition);
  appearance: none;
}
.lc-input::placeholder,
.lc-textarea::placeholder {
  color: var(--lc-text-faint);
}

.lc-input:hover,
.lc-select:hover,
.lc-textarea:hover {
  border-color: var(--lc-text-faint);
}

.lc-input:focus-visible,
.lc-select:focus-visible,
.lc-textarea:focus-visible {
  outline: 2px solid var(--lc-signal);
  outline-offset: 1px;
  border-color: var(--lc-signal);
}

.lc-input:disabled,
.lc-select:disabled,
.lc-textarea:disabled {
  background: var(--lc-disabled-bg);
  color: var(--lc-disabled-text);
  border-color: var(--lc-rule);
  cursor: not-allowed;
}

.lc-input[aria-invalid='true'],
.lc-select[aria-invalid='true'],
.lc-textarea[aria-invalid='true'] {
  border-color: var(--lc-signal);
}

.lc-textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.55;
}

/* Identifiers, keys, domains and amounts are mono — the same rule as the rest
   of the system. Set on the input, not just the display value. */
.lc-input--mono {
  font-family: var(--lc-font-mono);
  font-size: var(--lc-mono);
}

/* Native select needs its own caret since appearance is stripped.
   lint-ok 09 — the caret is two triangles cut from a hard 50% colour stop, not
   a gradient in the decorative sense the rule forbids. The alternative is an
   external SVG asset, and this system does not ship image files.
   lint-ok 10 — .lc-switch__track is 22px tall and must be a pill to read as a
   switch at all; its 11px radius is exactly half its height, not a soft corner. */
.lc-select {
  padding-right: var(--lc-space-8);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 51%,
    calc(100% - 13px) 51%;
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Prefix / suffix, for domains and currency */
.lc-input-group {
  display: flex;
  align-items: stretch;
  border: var(--lc-rule-width) solid var(--lc-rule-strong);
  border-radius: var(--lc-radius-action);
  background: var(--lc-ink-raised);
  overflow: hidden;
  min-width: 0;
}
.lc-input-group:focus-within {
  outline: 2px solid var(--lc-signal);
  outline-offset: 1px;
  border-color: var(--lc-signal);
}
.lc-input-group .lc-input {
  border: 0;
  border-radius: 0;
  outline: none !important;
}
.lc-input-group__affix {
  display: flex;
  align-items: center;
  padding-inline: var(--lc-space-4);
  font-family: var(--lc-font-mono);
  font-size: var(--lc-mono);
  color: var(--lc-text-faint);
  background: var(--lc-ink);
  white-space: nowrap;
}
.lc-input-group__affix:first-child {
  border-right: var(--lc-rule-width) solid var(--lc-rule);
}
.lc-input-group__affix:last-child {
  border-left: var(--lc-rule-width) solid var(--lc-rule);
}

/* ── Choice: checkbox, radio ───────────────────────────────────────
   Drawn as cells. The lit state uses signal, same as the mark. */

.lc-choice {
  display: flex;
  align-items: flex-start;
  gap: var(--lc-space-3);
  min-height: var(--lc-hit-min);
  padding-block: var(--lc-space-2);
  cursor: pointer;
  min-width: 0;
}
.lc-choice input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.lc-choice__box {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 2px;
  border: var(--lc-rule-width) solid var(--lc-rule-strong);
  border-radius: var(--lc-radius-cell);
  background: var(--lc-ink-raised);
  display: grid;
  place-items: center;
  transition:
    border-color var(--lc-transition),
    background var(--lc-transition);
}
.lc-choice--radio .lc-choice__box {
  border-radius: 50%;
}

.lc-choice:hover .lc-choice__box {
  border-color: var(--lc-text-faint);
}
.lc-choice input:focus-visible + .lc-choice__box {
  outline: 2px solid var(--lc-signal);
  outline-offset: 2px;
}

.lc-choice input:checked + .lc-choice__box {
  border-color: var(--lc-signal);
  background: var(--lc-signal);
}
.lc-choice input:checked + .lc-choice__box::after {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--lc-ink);
  border-radius: 1px;
}
.lc-choice--radio input:checked + .lc-choice__box::after {
  border-radius: 50%;
  width: 7px;
  height: 7px;
}

.lc-choice input:disabled + .lc-choice__box {
  background: var(--lc-disabled-bg);
  border-color: var(--lc-rule);
}
.lc-choice input:disabled ~ .lc-choice__text {
  color: var(--lc-disabled-text);
}

.lc-choice__text {
  min-width: 0;
}
.lc-choice__title {
  font-size: var(--lc-body-s);
  color: var(--lc-text);
  display: block;
}
.lc-choice__help {
  font-size: 13px;
  color: var(--lc-text-dim);
  display: block;
  margin-top: 2px;
}

/* ── Toggle ────────────────────────────────────────────────────────
   For a setting that takes effect immediately. If it needs a Save, use a
   checkbox instead — a switch that doesn't switch is a lie. */

.lc-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--lc-space-3);
  cursor: pointer;
  min-height: var(--lc-hit-min);
}
.lc-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.lc-switch__track {
  width: 38px;
  height: 22px;
  flex: none;
  border-radius: 11px;
  background: var(--lc-disabled-bg);
  border: var(--lc-rule-width) solid var(--lc-rule-strong);
  position: relative;
  transition:
    background var(--lc-transition),
    border-color var(--lc-transition);
}
.lc-switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--lc-text-dim);
  transition:
    transform var(--lc-transition),
    background var(--lc-transition);
}
.lc-switch input:checked + .lc-switch__track {
  background: var(--lc-signal);
  border-color: var(--lc-signal);
}
.lc-switch input:checked + .lc-switch__track::after {
  transform: translateX(16px);
  background: var(--lc-ink);
}
.lc-switch input:focus-visible + .lc-switch__track {
  outline: 2px solid var(--lc-signal);
  outline-offset: 2px;
}
.lc-switch input:disabled + .lc-switch__track {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Fieldset ──────────────────────────────────────────────────────
   A named group of controls, separated by a rule rather than boxed. */

.lc-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.lc-fieldset__legend {
  font-family: var(--lc-font-serif);
  font-size: var(--lc-heading-s);
  font-weight: 400;
  letter-spacing: var(--lc-heading-s-ls);
  color: var(--lc-text);
  padding: 0;
  margin-bottom: var(--lc-space-2);
}
.lc-fieldset__intro {
  font-size: var(--lc-body-s);
  color: var(--lc-text-dim);
  max-width: var(--lc-prose-max);
  margin: 0 0 var(--lc-space-6);
}

/* Settings row that carries a real control rather than a mono value. */
.lc-row-item__field {
  flex: 0 1 320px;
  min-width: 0;
}

/* Form actions — commit bar. Saves on commit, inline confirmation, no toast. */
.lc-form-actions {
  display: flex;
  align-items: center;
  gap: var(--lc-space-4);
  flex-wrap: wrap;
  padding-top: var(--lc-space-6);
  border-top: var(--lc-rule-width) solid var(--lc-rule);
}
.lc-form-actions__note {
  font-size: 13.5px;
  color: var(--lc-text-faint);
}
.lc-saved {
  display: inline-flex;
  align-items: center;
  gap: var(--lc-space-2);
  font-size: 13.5px;
  color: var(--lc-ok);
}
.lc-saved::before {
  content: '✓';
  font-family: var(--lc-font-mono);
}

/* ── Table ─────────────────────────────────────────────────────────
   A table is a cell grid with headers. Same shared-rule construction:
   one hairline between rows, none doubled at the edges. */

.lc-table-wrap {
  border: var(--lc-rule-width) solid var(--lc-rule);
  border-radius: var(--lc-radius-cell);
  overflow-x: auto;
  background: var(--lc-ink-raised);
}
.lc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--lc-body-s);
  min-width: 640px;
}
.lc-table thead th {
  font-family: var(--lc-font-mono);
  font-size: var(--lc-label);
  font-weight: 500;
  letter-spacing: var(--lc-label-ls);
  text-transform: uppercase;
  color: var(--lc-text-faint);
  text-align: left;
  padding: var(--lc-space-3) var(--lc-space-4);
  border-bottom: var(--lc-rule-width) solid var(--lc-rule);
  background: var(--lc-ink);
  white-space: nowrap;
}
.lc-table tbody td {
  padding: var(--lc-space-3) var(--lc-space-4);
  border-bottom: var(--lc-rule-width) solid var(--lc-rule);
  color: var(--lc-text-dim);
  vertical-align: middle;
}
.lc-table tbody tr:last-child td {
  border-bottom: 0;
}
.lc-table tbody tr:hover td {
  background: var(--lc-ink);
}

/* First column is the thing itself; it gets full-strength text. */
.lc-table__primary {
  color: var(--lc-text);
  font-weight: 500;
}
/* Identifiers, timestamps and amounts are mono. Amounts align right. */
.lc-table__mono {
  font-family: var(--lc-font-mono);
  font-size: 12.5px;
}
.lc-table__num {
  font-family: var(--lc-font-mono);
  font-size: 12.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lc-table th.lc-table__num {
  text-align: right;
}
.lc-table__actions {
  text-align: right;
  white-space: nowrap;
}

/* Sortable header */
.lc-table__sort {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  gap: var(--lc-space-1);
}
.lc-table__sort:hover {
  color: var(--lc-text);
}
.lc-table__sort[aria-sort='ascending']::after {
  content: '↑';
  color: var(--lc-signal);
}
.lc-table__sort[aria-sort='descending']::after {
  content: '↓';
  color: var(--lc-signal);
}

/* ── Toolbar above a table ─────────────────────────────────────── */

.lc-toolbar {
  display: flex;
  align-items: center;
  gap: var(--lc-space-3);
  flex-wrap: wrap;
  margin-bottom: var(--lc-space-4);
}
.lc-toolbar__spacer {
  margin-left: auto;
}
.lc-toolbar .lc-input,
.lc-toolbar .lc-select {
  width: auto;
  min-height: 38px;
  padding-block: var(--lc-space-2);
}
.lc-toolbar__count {
  font-family: var(--lc-font-mono);
  font-size: 12.5px;
  color: var(--lc-text-faint);
}

/* ── Tabs / segmented ──────────────────────────────────────────────
   A rule with one lit segment. Same language as the sidebar's current item. */

.lc-tabs {
  display: flex;
  gap: var(--lc-space-6);
  border-bottom: var(--lc-rule-width) solid var(--lc-rule);
  margin-bottom: var(--lc-space-6);
  overflow-x: auto;
}
.lc-tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: var(--lc-space-3) 0;
  font-family: var(--lc-font-sans);
  font-size: var(--lc-body-s);
  color: var(--lc-text-dim);
  cursor: pointer;
  white-space: nowrap;
  transition:
    color var(--lc-transition),
    border-color var(--lc-transition);
}
.lc-tab:hover {
  color: var(--lc-text);
}
.lc-tab[aria-selected='true'] {
  color: var(--lc-text);
  border-bottom-color: var(--lc-signal);
}

/* ── Pagination ────────────────────────────────────────────────── */

.lc-pager {
  display: flex;
  align-items: center;
  gap: var(--lc-space-3);
  margin-top: var(--lc-space-4);
  font-size: 13.5px;
  color: var(--lc-text-faint);
}
.lc-pager__range {
  font-family: var(--lc-font-mono);
  font-size: 12.5px;
}
.lc-pager__spacer {
  margin-left: auto;
}

/* ── Alert ─────────────────────────────────────────────────────────
   Inline, in place, next to the thing it concerns. The system has no toast
   stack: a message that outlives its context is a message you can't act on. */

.lc-alert {
  display: flex;
  gap: var(--lc-space-3);
  padding: var(--lc-space-4);
  border: var(--lc-rule-width) solid var(--lc-rule);
  border-left: 2px solid var(--lc-text-faint);
  border-radius: var(--lc-radius-cell);
  background: var(--lc-ink-raised);
  font-size: var(--lc-body-s);
  line-height: 1.55;
  color: var(--lc-text-dim);
  min-width: 0;
}
.lc-alert__title {
  font-size: var(--lc-body-s);
  font-weight: 500;
  color: var(--lc-text);
  margin: 0 0 2px;
}
.lc-alert__body {
  margin: 0;
}
.lc-alert__mark {
  font-family: var(--lc-font-mono);
  font-size: 12px;
  flex: none;
  padding-top: 2px;
  color: var(--lc-text-faint);
}

.lc-alert--warn {
  border-left-color: var(--lc-signal);
}
.lc-alert--warn .lc-alert__mark {
  color: var(--lc-signal);
}
.lc-alert--ok {
  border-left-color: var(--lc-ok);
}
.lc-alert--ok .lc-alert__mark {
  color: var(--lc-ok);
}

/* ── Modal and sheet ───────────────────────────────────────────────
   The dialog is the front layer. The page behind it takes
   .lc-page--behind-modal and drops back a layer — there is no scrim,
   because depth in this system is opacity, not a dark wash. */

.lc-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--lc-space-6);
  overflow-y: auto;
}
.lc-modal[hidden] {
  display: none;
}

.lc-modal__dialog {
  background: var(--lc-ink-raised);
  border: var(--lc-rule-width) solid var(--lc-rule-strong);
  border-radius: var(--lc-radius-cell);
  padding: var(--lc-space-8);
  width: min(520px, 100%);
  min-width: 0;
}
.lc-modal__title {
  font-family: var(--lc-font-serif);
  font-size: var(--lc-heading-m);
  font-weight: 400;
  letter-spacing: var(--lc-heading-m-ls);
  margin: 0 0 var(--lc-space-3);
}
.lc-modal__body {
  font-size: var(--lc-body-s);
  color: var(--lc-text-dim);
  margin: 0 0 var(--lc-space-6);
}
.lc-modal__actions {
  display: flex;
  gap: var(--lc-space-3);
  flex-wrap: wrap;
}

/* Destructive confirmation: the merchant types the resource name. */
.lc-confirm-name {
  font-family: var(--lc-font-mono);
  font-size: var(--lc-mono);
  color: var(--lc-text);
}

/* Sheet — full-width panel from the bottom on small screens. */
.lc-sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 100;
}
.lc-sheet__panel {
  background: var(--lc-ink-raised);
  border-top: var(--lc-rule-width) solid var(--lc-rule-strong);
  padding: var(--lc-space-6) var(--lc-space-6) var(--lc-space-8);
  max-height: 80vh;
  overflow-y: auto;
}

/* ── Empty, loading, error ─────────────────────────────────────────
   Three states every list needs. All three sit on the canvas, centred in
   the space the content would have occupied — never inside a cell. */

.lc-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--lc-space-3);
  padding: var(--lc-space-11) var(--lc-space-6);
  border: var(--lc-rule-width) dashed var(--lc-rule-strong);
  border-radius: var(--lc-radius-cell);
  max-width: var(--lc-prose-max);
}
.lc-state__title {
  font-family: var(--lc-font-serif);
  font-size: var(--lc-heading-s);
  font-weight: 400;
  margin: 0;
  color: var(--lc-text);
}
.lc-state__body {
  font-size: var(--lc-body-s);
  color: var(--lc-text-dim);
  margin: 0;
}
.lc-state__actions {
  display: flex;
  gap: var(--lc-space-3);
  flex-wrap: wrap;
  margin-top: var(--lc-space-1);
}

/* Loading — cells that haven't filled yet. Pulse only, never a spinner:
   a skeleton tells you the shape of what is coming. */
.lc-skeleton {
  background: var(--lc-rule);
  border-radius: var(--lc-radius-cell);
  height: 1em;
  width: 100%;
  animation: lc-pulse 1.4s ease-in-out infinite;
}
.lc-skeleton--text {
  height: 0.75em;
}
.lc-skeleton--w-60 {
  width: 60%;
}
.lc-skeleton--w-40 {
  width: 40%;
}
.lc-skeleton--w-25 {
  width: 25%;
}
.lc-skeleton--figure {
  height: 32px;
  width: 45%;
}

@keyframes lc-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.lc-loading-rows {
  display: flex;
  flex-direction: column;
  gap: var(--lc-space-4);
}

/* ── Plan / pricing cell ───────────────────────────────────────────
   Three cells sharing rules. The number is the headline, in serif.
   No "contact us" tier on a self-serve app. No crossed-out anchor price. */

.lc-plan {
  display: flex;
  flex-direction: column;
  gap: var(--lc-space-3);
  min-width: 0;
}
.lc-plan__name {
  font-size: var(--lc-body-s);
  font-weight: 500;
  color: var(--lc-text);
}
.lc-plan__who {
  font-size: 13px;
  color: var(--lc-text-faint);
  min-height: 2.6em;
}
.lc-plan__price {
  display: flex;
  align-items: baseline;
  gap: var(--lc-space-2);
  flex-wrap: wrap;
}
.lc-plan__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--lc-space-2);
  font-size: 13.5px;
  color: var(--lc-text-dim);
}
.lc-plan__list li {
  display: flex;
  gap: var(--lc-space-2);
}
.lc-plan__list li::before {
  content: '·';
  color: var(--lc-text-faint);
}
.lc-plan__cta {
  margin-top: var(--lc-space-2);
}

/* The recommended plan is marked with a note in signal, not a colour fill or a
   badge shout. It is a real element, not generated content: .lc-cells clips,
   so anything offset above the cell would be discarded — and a generated string
   is invisible to both screen readers and the generator filling these pages. */
.lc-plan__note {
  font-family: var(--lc-font-mono);
  font-size: var(--lc-label);
  font-weight: 500;
  letter-spacing: var(--lc-label-ls);
  text-transform: uppercase;
  color: var(--lc-signal);
  margin: 0;
}
/* Plans without a note reserve the same line, so the three names stay aligned. */
.lc-plan__note--none {
  visibility: hidden;
}

/* ── Mobile navigation ─────────────────────────────────────────────
   The header nav collapses below 640. This is what replaces it. */

.lc-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--lc-hit-min);
  height: var(--lc-hit-min);
  margin-right: calc(var(--lc-space-3) * -1);
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--lc-text);
}
.lc-nav-toggle span,
.lc-nav-toggle span::before,
.lc-nav-toggle span::after {
  display: block;
  width: 18px;
  height: 1px;
  background: currentColor;
  content: '';
}
.lc-nav-toggle span {
  position: relative;
}
.lc-nav-toggle span::before {
  position: absolute;
  top: -5px;
}
.lc-nav-toggle span::after {
  position: absolute;
  top: 5px;
}

.lc-nav-sheet {
  display: none;
  border-bottom: var(--lc-rule-width) solid var(--lc-rule);
  background: var(--lc-ink);
}
.lc-nav-sheet__inner {
  padding: var(--lc-space-4) var(--lc-space-6) var(--lc-space-6);
  display: flex;
  flex-direction: column;
}
.lc-nav-sheet a:not(.lc-btn) {
  padding-block: var(--lc-space-3);
  min-height: var(--lc-hit-min);
  display: flex;
  align-items: center;
  font-size: var(--lc-body);
  color: var(--lc-text-dim);
  border-bottom: var(--lc-rule-width) solid var(--lc-rule);
}
.lc-nav-sheet a:not(.lc-btn):hover {
  color: var(--lc-text);
  text-decoration: none;
}
.lc-nav-sheet .lc-btn {
  margin-top: var(--lc-space-4);
  justify-content: center;
}

@media (max-width: 640px) {
  .lc-nav-toggle {
    display: inline-flex;
  }
  .lc-nav-sheet[data-open='true'] {
    display: block;
  }
  .lc-row-item__field {
    flex: 1 1 100%;
  }
  .lc-modal {
    padding: 0;
    place-items: end stretch;
  }
  .lc-modal__dialog {
    width: 100%;
    border-radius: 0;
    border-inline: 0;
    border-bottom: 0;
    padding: var(--lc-space-6);
  }
  .lc-form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .lc-form-actions .lc-btn {
    justify-content: center;
  }
}
