/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 *
 * This file is unlayered CSS, so it wins over the Tailwind build's layered
 * rules (theme/base/utilities) regardless of load order — the app-wide state
 * rules below rely on that. Design tokens (--color-*) come from the Tailwind
 * @theme and are readable here as plain custom properties.
 */

/* Form field groups — invalid-field treatment. Rails wraps a field (and its
   label) that failed validation in <div class="field_with_errors">; the
   wrapper gets display:contents so it never disturbs the form's layout,
   while the control inside gets the err border + soft err ring and the
   label turns err so "fix the highlighted fields" actually highlights. */
.field_with_errors {
  display: contents;
}

.field_with_errors :is(input, select, textarea) {
  border-color: var(--color-err);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-err) 14%, transparent);
}

.field_with_errors label {
  color: var(--color-err);
}

/* Keyboard focus discipline: one accent focus-visible ring app-wide, so
   tabbing looks deliberate against indigo surfaces instead of the browser
   default. Text controls opt out — they already carry their own accent
   border + soft ring focus treatment (and it fires on any focus, not just
   keyboard). Checkboxes/radios keep the outline. */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

:is(input:not([type="checkbox"]):not([type="radio"]), textarea, select):focus-visible {
  outline: none;
}

/* ------------------------------------------------------------------------
   Knowledge Center article body (.article-body wraps Knowledge::Markdown
   output on the article page). Report tables + mermaid charts in the
   indigo/gold vocabulary. Selectors are compounded with .md so they win
   over the generic .md prose rules at equal load order. */

.md.article-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.25em 0;
  font-size: 0.95em;
  border: 1px solid var(--color-line);
  border-radius: 0.75rem;
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.md.article-body th,
.md.article-body td {
  border: 0;
  padding: 0.6em 0.9em;
  text-align: left;
  vertical-align: top;
}

/* Header row: eyebrow treatment on a soft indigo tint, underscored in gold */
.md.article-body thead th {
  background: var(--color-accent-soft);
  border-bottom: 2px solid var(--color-star);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink);
}

.md.article-body tbody td {
  border-bottom: 1px solid var(--color-line-subtle);
  color: var(--color-ink-2);
}

.md.article-body tbody tr:last-child td {
  border-bottom: 0;
}

/* Zebra: barely-there periwinkle wash on even rows */
.md.article-body tbody tr:nth-child(even) td {
  background: color-mix(in oklab, var(--color-surface-2) 45%, transparent);
}

/* Rounded corners survive border-collapse: separate via the corner cells */
.md.article-body thead th:first-child { border-top-left-radius: 0.7rem; }
.md.article-body thead th:last-child { border-top-right-radius: 0.7rem; }
.md.article-body tbody tr:last-child td:first-child { border-bottom-left-radius: 0.7rem; }
.md.article-body tbody tr:last-child td:last-child { border-bottom-right-radius: 0.7rem; }

/* Mermaid chart blocks: source arrives as an escaped code block and stays
   one if the chart is invalid; a rendered chart sits centered on a card. */
.md.article-body pre.mermaid {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 0.75rem;
  padding: 1.15em;
  margin: 1.25em 0;
  overflow-x: auto;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.85em;
  color: var(--color-ink-2);
}

.md.article-body pre.mermaid[data-knowledge-chart="rendered"] {
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.md.article-body pre.mermaid svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}
