/* =========================================================================
   Barázda — component library
   Layers: components, utilities. Load after layout.css.

   Everything here is shared between the landing page, the login page and
   (by design) the future app screens. Page-specific rules live in
   landing.css / login.css, never here.
   ========================================================================= */

@layer components {
  /* =====================================================================
     BUTTONS
     44px minimum height, 48px for primary and for everything on mobile —
     these get pressed with a gloved thumb in a field, not a trackpad.
     ===================================================================== */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    min-height: var(--size-control-h);
    padding-inline: var(--space-md);
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    font-family: var(--font-body);
    font-size: var(--font-size-body-sm);
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    background-color: transparent;
    color: var(--text-primary);
    transition: background-color var(--dur-fast) var(--ease-standard),
      border-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
  }

  .btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
  }

  /* aria-disabled, not the disabled attribute: the control stays focusable
     and readable to assistive tech, and the reason is announced with it.
     Handlers early-return instead of relying on the browser. */
  .btn[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.6;
  }

  .btn--primary {
    background-color: var(--brand-solid);
    color: var(--on-brand);
    border-color: var(--brand-solid);
  }

  .btn--primary:hover:not([aria-disabled="true"]) {
    background-color: var(--brand-solid-hover);
    border-color: var(--brand-solid-hover);
    color: var(--on-brand);
  }

  .btn--primary:active:not([aria-disabled="true"]) {
    background-color: var(--brand-solid-active);
  }

  .btn--secondary {
    background-color: var(--surface-raised);
    color: var(--text-primary);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-xs);
  }

  .btn--secondary:hover:not([aria-disabled="true"]) {
    background-color: var(--surface-subtle);
    color: var(--text-primary);
  }

  .btn--ghost {
    color: var(--text-secondary);
  }

  .btn--ghost:hover:not([aria-disabled="true"]) {
    background-color: var(--surface-subtle);
    color: var(--text-primary);
  }

  .btn--lg {
    min-height: var(--size-control-h-lg);
    padding-inline: var(--space-lg);
    font-size: var(--font-size-body);
  }

  .btn--block {
    width: 100%;
  }

  .btn .icon {
    flex: none;
  }

  /* Icon-only control. The accessible name comes from aria-label; the SVG
     inside is always aria-hidden. */
  .btn--icon {
    width: var(--size-tap-min);
    min-height: var(--size-tap-min);
    padding: 0;
    color: var(--text-secondary);
  }

  .btn--icon:hover:not([aria-disabled="true"]) {
    background-color: var(--surface-subtle);
    color: var(--text-primary);
  }

  @media (max-width: 40rem) {
    /* Every control goes to 48px on phones. */
    .btn {
      min-height: var(--size-control-h-lg);
    }
  }

  /* Spinner shown while a form is in flight. Under reduced motion the
     rotation stops and the label ("Signing in…") does the communicating,
     which it was doing anyway. */
  .btn__spinner {
    width: 1rem;
    height: 1rem;
    flex: none;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: barazda-spin 900ms linear infinite;
  }

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

  @media (prefers-reduced-motion: reduce) {
    .btn__spinner {
      animation: none;
      border-top-color: currentColor;
      opacity: 0.5;
    }
  }

  /* =====================================================================
     ICONS
     ===================================================================== */
  .icon {
    width: var(--size-icon);
    height: var(--size-icon);
    flex: none;
  }

  .icon--sm {
    width: var(--size-icon-sm);
    height: var(--size-icon-sm);
  }

  @media (forced-colors: active) {
    .icon {
      forced-color-adjust: auto;
    }
  }

  /* =====================================================================
     BADGES / STATUS CHIPS
     Status is legible three ways: the word itself, the dot's fill or
     outline, and the border style. Colour is never load-bearing on its own.
     ===================================================================== */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.15em 0.55em;
    border: 1px solid var(--neutral-border);
    border-radius: var(--radius-chip);
    background-color: var(--neutral-surface);
    color: var(--neutral-fg);
    font-size: var(--font-size-caption);
    font-weight: 600;
    line-height: 1.45;
    white-space: nowrap;
  }

  .badge::before {
    content: "";
    width: 6px;
    height: 6px;
    flex: none;
    border-radius: 50%;
    background-color: var(--neutral-solid);
  }

  .badge[data-status="live"] {
    background-color: var(--status-live-surface);
    border-color: var(--status-live-border);
    color: var(--status-live-fg);
  }

  .badge[data-status="live"]::before {
    background-color: var(--status-live-dot);
    /* Plain rgba first so the halo still draws where color-mix() is
       unsupported — the shorthand recipe for gradients does not cover a
       box-shadow, so it is spelled out here. */
    box-shadow: 0 0 0 3px rgba(42, 125, 78, 0.22);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--status-live-dot) 22%, transparent);
  }

  .badge[data-status="beta"] {
    background-color: var(--status-beta-surface);
    border-color: var(--status-beta-border);
    color: var(--status-beta-fg);
  }

  /* Hollow dot: differentiates Beta from Live by SHAPE, not just hue. */
  .badge[data-status="beta"]::before {
    background-color: transparent;
    box-shadow: inset 0 0 0 2px var(--status-beta-dot);
  }

  .badge[data-status="roadmap"] {
    background-color: var(--status-roadmap-surface);
    border-color: var(--status-roadmap-border);
    border-style: dashed;
    color: var(--status-roadmap-fg);
  }

  .badge[data-status="roadmap"]::before {
    background-color: var(--status-roadmap-dot);
  }

  .badge--accent {
    background-color: var(--accent-wash);
    border-color: var(--accent-border);
    color: var(--accent-fg);
  }

  .badge--accent::before {
    background-color: var(--accent-solid);
  }

  /* Legend above the module grid. */
  .badge-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-md);
    color: var(--text-muted);
    font-size: var(--font-size-caption);
  }

  .badge-legend > li {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
  }

  /* Filter chips (farm type). Real <button>s in a group, not links. */
  .chip {
    display: inline-flex;
    align-items: center;
    min-height: var(--size-tap-min);
    padding-inline: var(--space-sm);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background-color: var(--surface-raised);
    color: var(--text-secondary);
    font-size: var(--font-size-body-sm);
    font-weight: 550;
    cursor: pointer;
  }

  .chip:hover {
    background-color: var(--surface-subtle);
    color: var(--text-primary);
  }

  .chip[aria-pressed="true"] {
    background-color: var(--brand-solid);
    border-color: var(--brand-solid);
    color: var(--on-brand);
  }

  .chip:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
  }

  /* =====================================================================
     CARDS
     ===================================================================== */
  .card {
    position: relative;
    padding: var(--space-card-pad);
    background-color: var(--surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
  }

  /* MODULE CARD — what the registry renders. Adding a module adds one of
     these; nothing about this rule knows which modules exist. */
  .module-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    transition: border-color var(--dur-base) var(--ease-standard),
      box-shadow var(--dur-base) var(--ease-standard);
  }

  .module-card:hover {
    border-color: var(--border-brand);
    box-shadow: var(--shadow-md);
  }

  .module-card__head {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .module-card__icon {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    flex: none;
    border-radius: var(--radius-md);
    background-color: var(--brand-wash);
    border: 1px solid var(--brand-border);
    color: var(--brand-fg);
  }

  .module-card__icon .icon {
    width: 1.375rem;
    height: 1.375rem;
  }

  .module-card__titles {
    min-width: 0;
    flex: 1;
  }

  .module-card__name {
    font-size: var(--font-size-h4);
    font-weight: 620;
    letter-spacing: -0.006em;
  }

  .module-card__tagline {
    color: var(--accent-fg);
    font-size: var(--font-size-caption);
    font-weight: 550;
  }

  .module-card__desc {
    color: var(--text-secondary);
    font-size: var(--font-size-body-sm);
  }

  .module-card__features {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
    margin-block-start: auto;
    padding-block-start: var(--space-sm);
    border-block-start: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: var(--font-size-data);
  }

  .module-card__features li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2xs);
  }

  .module-card__features .icon {
    margin-block-start: 0.15em;
    color: var(--success-fg);
  }

  .module-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2xs) var(--space-xs);
    color: var(--text-muted);
    font-size: var(--font-size-caption);
  }

  /* Roadmap modules read as clearly not-yet-available without being so
     faded that they fail contrast. */
  .module-card[data-status="roadmap"] {
    background-color: var(--surface-raised-2);
    border-style: dashed;
  }

  /* =====================================================================
     STATS BAND
     ===================================================================== */
  .stat {
    position: relative;
    padding: var(--space-md) 0;
  }

  .stat__value {
    display: block;
    font-family: var(--font-display);
    font-size: var(--font-size-metric);
    font-weight: 620;
    line-height: 1;
    letter-spacing: -0.028em;
    font-variant-numeric: tabular-nums lining-nums;
  }

  .stat__value::after {
    content: "";
    display: block;
    width: 2rem;
    height: 2px;
    margin-block-start: var(--space-xs);
    background-color: var(--accent-solid);
    border-radius: var(--radius-pill);
  }

  .stat__label {
    display: block;
    margin-block-start: var(--space-xs);
    color: var(--text-secondary);
    font-size: var(--font-size-body-sm);
  }

  .stats__note {
    margin-block-start: var(--space-lg);
    max-width: var(--size-prose-max);
    color: var(--text-muted);
    font-size: var(--font-size-caption);
  }

  /* =====================================================================
     STEPS (how it works)
     ===================================================================== */
  .step {
    position: relative;
    padding-block-start: var(--space-md);
    border-block-start: 2px solid var(--border-brand);
  }

  .step__num {
    display: block;
    font-family: var(--font-display);
    font-size: var(--font-size-metric-sm);
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums lining-nums;
  }

  .step h3 {
    margin-block: var(--space-2xs) var(--space-xs);
  }

  .step p {
    color: var(--text-secondary);
    font-size: var(--font-size-body-sm);
  }

  /* =====================================================================
     QUOTES / TESTIMONIALS
     No avatar slot: there are no image files in this project and adding one
     would break the file:// guarantee for the sake of a stock photo.
     ===================================================================== */
  .quote {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-card-pad);
    background-color: var(--surface-raised);
    border: 1px solid var(--border-default);
    border-inline-start: 2px solid var(--accent-border);
    border-radius: var(--radius-card);
  }

  .quote blockquote {
    margin: 0;
    font-size: var(--font-size-body-lg);
    line-height: 1.55;
    text-wrap: pretty;
  }

  .quote figcaption {
    margin-block-start: auto;
  }

  .quote__name {
    font-size: var(--font-size-body-sm);
    font-weight: 600;
  }

  .quote__role,
  .quote__farm {
    display: block;
    color: var(--text-muted);
    font-size: var(--font-size-data);
  }

  /* =====================================================================
     PRICING
     The featured tier is marked with a TEXT chip, never colour alone, and
     the DOM order never changes with viewport — visual order and focus
     order must not diverge (SC 1.3.2 / 2.4.3).
     ===================================================================== */
  .price-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-card-pad);
    background-color: var(--surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
  }

  .price-card--featured {
    border-color: var(--border-brand);
    box-shadow: var(--shadow-md);
  }

  .price-card__flag {
    align-self: flex-start;
    padding: 0.15em 0.6em;
    border-radius: var(--radius-chip);
    background-color: var(--brand-solid);
    color: var(--on-brand);
    font-size: var(--font-size-caption);
    font-weight: 600;
  }

  .price__figure {
    font-family: var(--font-display);
    font-size: var(--font-size-metric-sm);
    font-weight: 620;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums lining-nums;
  }

  .price__period {
    display: block;
    color: var(--text-muted);
    font-size: var(--font-size-caption);
  }

  .price__blurb {
    color: var(--text-secondary);
    font-size: var(--font-size-body-sm);
  }

  .price__includes {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    font-size: var(--font-size-body-sm);
  }

  .price__includes li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .price__includes .icon {
    margin-block-start: 0.15em;
    color: var(--success-fg);
  }

  .price-card .btn {
    margin-block-start: auto;
  }

  .price__note {
    margin-block-start: var(--space-lg);
    max-width: var(--size-prose-max);
    color: var(--text-muted);
    font-size: var(--font-size-caption);
  }

  .price__note > * + * {
    margin-block-start: var(--space-2xs);
  }

  /* =====================================================================
     DISCLOSURE (FAQ)
     Native <details>. No single-open accordion logic: that breaks Ctrl+F,
     breaks printing, and hides five of six answers from anyone scanning.
     ===================================================================== */
  .disclosure {
    border-block-end: 1px solid var(--border-subtle);
  }

  .disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    min-height: var(--size-tap-min);
    padding-block: var(--space-md);
    font-size: var(--font-size-h4);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
  }

  .disclosure > summary::-webkit-details-marker {
    display: none;
  }

  .disclosure > summary:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
  }

  .disclosure > summary:hover {
    color: var(--brand-fg);
  }

  .disclosure__chevron {
    flex: none;
    color: var(--text-muted);
    transition: transform var(--dur-base) var(--ease-standard);
  }

  .disclosure[open] > summary .disclosure__chevron {
    transform: rotate(180deg);
  }

  .disclosure__body {
    max-width: var(--size-prose-max);
    padding-block-end: var(--space-lg);
    color: var(--text-secondary);
  }

  /* =====================================================================
     FORM FIELDS
     Used by login today; every module form later.
     ===================================================================== */
  .field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
  }

  .field__label {
    font-size: var(--font-size-body-sm);
    font-weight: 600;
  }

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

  .field__error {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2xs);
    color: var(--danger-fg);
    font-size: var(--font-size-caption);
    font-weight: 550;
  }

  .field__error .icon {
    margin-block-start: 0.1em;
  }

  .input {
    width: 100%;
    min-height: var(--size-control-h-lg);
    padding: var(--space-xs) var(--space-sm);
    background-color: var(--surface-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    font-size: var(--font-size-body);
  }

  .input::placeholder {
    color: var(--text-disabled);
  }

  .input:focus-visible {
    outline: none;
    border-color: var(--brand-solid);
    box-shadow: var(--shadow-focus);
  }

  .input[aria-invalid="true"] {
    border-color: var(--danger-fg);
    /* Error is signalled by icon + text + border WEIGHT, not red alone. */
    border-width: 2px;
  }

  .input[readonly] {
    background-color: var(--surface-subtle);
    color: var(--text-secondary);
  }

  /* Password field with its reveal button sharing one bordered box. */
  .input-group {
    position: relative;
    display: flex;
    align-items: center;
  }

  .input-group .input {
    padding-inline-end: calc(var(--size-tap-min) + var(--space-2xs));
  }

  .input-group__action {
    position: absolute;
    inset-inline-end: 2px;
    width: var(--size-tap-min);
    height: calc(100% - 4px);
    display: grid;
    place-items: center;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
  }

  .input-group__action:hover {
    color: var(--text-primary);
    background-color: var(--surface-subtle);
  }

  .input-group__action:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
  }

  .checkbox {
    display: flex;
    align-items: flex-start;
    gap: var(--space-xs);
    /* The whole row is the target, not just the 16px box. */
    min-height: var(--size-tap-min);
    padding-block: var(--space-2xs);
    cursor: pointer;
  }

  .checkbox input {
    width: 1.125rem;
    height: 1.125rem;
    margin-block-start: 0.2em;
    flex: none;
    accent-color: var(--brand-solid);
  }

  .checkbox input:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-xs);
  }

  .checkbox__text {
    font-size: var(--font-size-body-sm);
  }

  .select {
    min-height: var(--size-control-h);
    padding: var(--space-2xs) var(--space-sm);
    background-color: var(--surface-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    font-size: var(--font-size-body-sm);
  }

  /* =====================================================================
     BANNERS / ERROR SUMMARY
     All of these sit in NORMAL FLOW. Nothing on this site is
     position: fixed over a form, so a focused input can never end up behind
     an overlay on a 320px screen with the keyboard up (SC 2.4.11).
     ===================================================================== */
  .banner {
    display: flex;
    align-items: flex-start;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--info-border);
    border-radius: var(--radius-control);
    background-color: var(--info-surface);
    color: var(--info-fg);
    font-size: var(--font-size-body-sm);
  }

  .banner .icon {
    margin-block-start: 0.15em;
  }

  .banner[data-tone="warning"] {
    border-color: var(--warning-border);
    background-color: var(--warning-surface);
    color: var(--warning-fg);
  }

  .banner[data-tone="success"] {
    border-color: var(--success-border);
    background-color: var(--success-surface);
    color: var(--success-fg);
  }

  .banner[data-tone="danger"] {
    border-color: var(--danger-border);
    background-color: var(--danger-surface);
    color: var(--danger-fg);
  }

  /* The error summary is FOCUSED on failure rather than announced via a
     live region. Focusing it makes the screen reader read the heading and
     the whole list, which is more reliable; adding role="alert" as well
     causes double or truncated announcements, so it is deliberately absent. */
  .error-summary {
    padding: var(--space-md);
    border: 2px solid var(--danger-fg);
    border-radius: var(--radius-control);
    background-color: var(--danger-surface);
  }

  .error-summary:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
  }

  .error-summary h2 {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-h4);
    color: var(--danger-fg);
  }

  .error-summary ul {
    margin-block-start: var(--space-xs);
    padding-inline-start: var(--space-md);
  }

  .error-summary a {
    color: var(--danger-fg);
    font-size: var(--font-size-body-sm);
    font-weight: 550;
  }

  /* =====================================================================
     DIALOG — used for the "not part of this build" stub, so that no link
     on the site is dead.
     ===================================================================== */
  .dialog {
    width: min(100% - 2rem, 28rem);
    padding: var(--space-lg);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    background-color: var(--surface-raised);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
  }

  .dialog::backdrop {
    background-color: var(--overlay-scrim);
  }

  .dialog h2 {
    font-size: var(--font-size-h3);
  }

  .dialog p {
    margin-block: var(--space-sm) var(--space-lg);
    color: var(--text-secondary);
    font-size: var(--font-size-body-sm);
  }

  /* =====================================================================
     WELL — sunken panel used for map/chart placeholders and empty states.
     ===================================================================== */
  .well {
    position: relative;
    overflow: hidden;
    padding: var(--space-lg);
    background-color: var(--surface-sunken);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-well);
  }
}

@layer utilities {
  /* Visually hidden but present for assistive tech. Not display:none, which
     removes it from the accessibility tree entirely. */
  .u-visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  /* Tabular figures so "1,430" and "5.5 hrs" do not jitter against each
     other in the stats band, price table, or any [data-unit] output. */
  .u-tabular {
    font-variant-numeric: tabular-nums lining-nums;
  }

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

  .u-secondary {
    color: var(--text-secondary);
  }

  .u-caption {
    font-size: var(--font-size-caption);
  }

  .u-center {
    text-align: center;
  }

  .u-prose {
    max-width: var(--size-prose-max);
  }

  [hidden] {
    display: none !important;
  }
}
