/* AI Field Manual: product layer on top of family.css.
   Identity: a technical manual. Catalogue codes in mono, ruled spec sheets,
   square step numbers, checkpoints after every step. One accent: cobalt
   ink, used for action, focus, the current filter and step numbers only. */

:root {
  --accent: #2c4f94;
  --accent-hover: #1d3a72;
  --accent-soft: #dde4f0;
  --on-accent: #fbf9f5;
  --focus: #2c4f94;
  --caution: #8a4a00;
}

[data-theme="dark"] {
  --accent: #9db9ef;
  --accent-hover: #c1d3f6;
  --accent-soft: #1f2738;
  --on-accent: #0f1522;
  --focus: #9db9ef;
  --caution: #f0b66a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #9db9ef;
    --accent-hover: #c1d3f6;
    --accent-soft: #1f2738;
    --on-accent: #0f1522;
    --focus: #9db9ef;
    --caution: #f0b66a;
  }
}

/* ---- Intro: headline beside the task index (no empty hero) ------------- */

.intro {
  padding: var(--space-6) 0 var(--space-6);
  border-bottom: 1px solid var(--border);
}

.intro-grid {
  display: grid;
  gap: var(--space-6);
}

.intro h1 {
  max-width: 15em;
  margin-bottom: var(--space-4);
}

.intro .lead {
  margin-bottom: var(--space-5);
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: 0;
}

@media (min-width: 1024px) {
  .intro-grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: var(--space-8);
    align-items: end;
  }
}

.task-index {
  border-top: 2px solid var(--rule);
}

.task-index-title {
  margin: var(--space-3) 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-style: italic;
  font-weight: 500;
}

.task-index ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-index li {
  margin: 0;
}

.task-index a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--target);
  padding: var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background-color var(--dur-fast) ease;
}

.task-index a:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.task-index a:hover .ti-label {
  text-decoration: underline;
}

.ti-count {
  min-width: 2rem;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: right;
}

/* ---- Finder controls ------------------------------------------------------ */

.finder {
  padding: var(--space-6) 0 var(--space-5);
}

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

.finder-controls.js-only {
  display: none;
}

.js .finder-controls.js-only {
  display: grid;
}

.finder-controls {
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.search-wrap {
  position: relative;
}

.search-wrap .input {
  padding-right: 3rem;
  font-size: var(--text-md);
}

.search-wrap kbd {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.field-tasks .chip-row {
  margin-top: var(--space-1);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: var(--space-3);
  align-items: end;
}

.finder-nojs {
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

/* ---- The ledger of skills ------------------------------------------------ */

.skill-list {
  margin: 0 0 var(--space-5);
  padding: 0;
  list-style: none;
  border-top: 2px solid var(--rule);
}

.skill-list > li + li {
  margin-top: 0;
}

.skill {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2) var(--space-5);
  padding: var(--space-4) var(--space-2);
  border-bottom: 1px solid var(--border);
  transition: background-color var(--dur-fast) ease;
}

.skill:hover {
  background: var(--surface-raised);
}

.skill-code {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.skill-title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-lg);
  line-height: 1.3;
}

.skill-title a {
  color: var(--text);
  text-decoration: none;
}

.skill-title a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* The title link covers the row; nothing else in a row is interactive. */
.skill-title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.skill-title a:focus-visible {
  outline-color: transparent;
}

.skill-title a:focus-visible::after {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

.skill-outcome {
  max-width: 62ch;
  margin: 0 0 var(--space-1);
  color: var(--text-muted);
}

.label,
.skill-specs dt,
.facts dt,
.spec-list dt {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.skill-outcome .label {
  margin-right: var(--space-1);
  color: var(--text);
}

.skill-facets {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.skill-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2) var(--space-4);
  margin: var(--space-2) 0 0;
}

.skill-specs dd,
.facts dd {
  margin: 0;
  font-size: var(--text-sm);
}

@media (min-width: 769px) {
  .skill {
    grid-template-columns: 4.25rem minmax(0, 1fr) minmax(0, 19rem);
    align-items: start;
    padding-inline: var(--space-3);
  }

  .skill-code {
    padding-top: 0.35rem;
  }

  .skill-specs {
    margin-top: 0;
  }
}

/* Level meter: one, two or three filled bars (shape, not colour). */
.level {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.meter {
  display: inline-flex;
  gap: 2px;
  color: var(--text);
}

.meter span {
  width: 5px;
  height: 0.8rem;
  border: 1px solid currentColor;
  border-radius: 1px;
}

.meter-1 span:nth-child(-n + 1),
.meter-2 span:nth-child(-n + 2),
.meter-3 span {
  background: currentColor;
}

/* Environment marks: full = solid edge and filled square, partial = dashed
   edge and half-filled square. */
.env-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.env-list li + li {
  margin-top: 0;
}

.env {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.5rem;
  padding: 0 0.4rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
}

.env::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border: 1px solid currentColor;
  background: currentColor;
}

.env-partial {
  border-style: dashed;
  border-color: var(--border-strong);
  background: transparent;
}

.env-partial::before {
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

/* Review record badges. */
.status {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

.badge-reviewed {
  color: var(--success);
}

.badge-needs-review {
  color: var(--caution);
}

.badge-needs-review::before {
  border-radius: 0;
  transform: rotate(45deg);
}

.badge-due {
  color: var(--danger);
}

.badge-due::before {
  border-radius: 0;
}

.badge-draft {
  border-style: dashed;
}

.badge-draft::before {
  border: 1.5px solid currentColor;
  background: transparent;
}

.status-date,
.demo-note {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* ---- Legend ---------------------------------------------------------------- */

.legend {
  padding: var(--space-6) 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.legend-title {
  font-size: var(--text-lg);
}

.legend-grid {
  display: grid;
  gap: var(--space-5);
}

.legend-grid h3 {
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.legend-list {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.legend-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
}

.legend-list .level,
.legend-list .badge,
.legend-list .env-list {
  color: var(--text);
}

.legend-list .badge-reviewed {
  color: var(--success);
}

.legend-list .badge-needs-review {
  color: var(--caution);
}

.legend-list .badge-due {
  color: var(--danger);
}

@media (min-width: 769px) {
  .legend-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---- Breadcrumbs ----------------------------------------------------------- */

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
}

.crumbs li {
  display: inline-flex;
  align-items: center;
  margin: 0;
  color: var(--text-muted);
}

.crumbs li + li::before {
  content: "/";
  padding: 0 var(--space-2);
  color: var(--border-strong);
}

.crumbs a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
}

/* ---- Spec sheet (one skill) ----------------------------------------------- */

.sheet-head {
  padding: var(--space-4) 0 var(--space-5);
  border-bottom: 1px solid var(--border);
}

.sheet-code {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}

.sheet-head h1 {
  max-width: 20em;
  margin-bottom: var(--space-3);
}

.outcome {
  max-width: 70ch;
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--accent);
  background: var(--surface-raised);
}

.outcome p {
  margin: 0;
}

.outcome-label {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.outcome-text {
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.45;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  margin: 0;
}

.facts > div {
  display: grid;
  gap: 0.15rem;
}

.facts a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target);
  margin-top: -0.6rem;
  margin-bottom: -0.6rem;
}

.sheet-grid {
  display: grid;
  gap: var(--space-6);
  padding-top: var(--space-5);
}

@media (min-width: 1024px) {
  .sheet-grid {
    grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
    gap: var(--space-7);
  }

  .spec {
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
    align-self: start;
    max-height: calc(100vh - var(--header-height) - var(--space-6));
    overflow-y: auto;
  }
}

.spec {
  padding-top: var(--space-3);
  border-top: 2px solid var(--rule);
}

.spec-title {
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spec-list {
  margin: 0 0 var(--space-4);
}

.spec-list > div {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.spec-list dd {
  margin: 0;
  font-size: var(--text-sm);
}

.spec-note {
  display: block;
  margin-top: var(--space-1);
  color: var(--text-muted);
}

.spec-sub {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-base);
}

.compat {
  font-size: var(--text-sm);
}

.compat th[scope="row"] {
  color: var(--text);
  font-weight: 600;
}

.support {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
}

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

.spec-record {
  margin-bottom: var(--space-2);
}

.spec-foot {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.sheet-block {
  padding: var(--space-5) 0 var(--space-2);
  border-top: 1px solid var(--border);
}

.sheet-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.sheet-block h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-lg);
}

.fit-cols {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 600px) {
  .fit-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.fit-cols h3 {
  margin-bottom: var(--space-2);
  font-size: var(--text-base);
}

/* Check and cross marks drawn in CSS, as on the portal's boundary lists. */
.mark-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mark-list li {
  position: relative;
  margin: 0;
  padding: var(--space-2) 0 var(--space-2) var(--space-5);
  border-top: 1px solid var(--border);
}

.mark-list li::before {
  content: "";
  position: absolute;
  left: 0.125rem;
  top: calc(var(--space-2) + 0.45em);
  width: 0.75rem;
  height: 0.75rem;
}

.mark-yes li::before {
  height: 0.4rem;
  top: calc(var(--space-2) + 0.5em);
  color: var(--success);
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

.mark-no li::before {
  color: var(--text-muted);
  background: linear-gradient(45deg, transparent 42%, currentColor 42% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, currentColor 42% 58%, transparent 58%);
}

.prereq-list {
  max-width: 68ch;
}

/* Steps: square numbers (a manual, not a slide deck), checkpoint below. */
.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step {
  position: relative;
  margin: 0;
  padding: var(--space-4) 0 var(--space-4) 3.25rem;
  border-top: 1px solid var(--border);
  counter-increment: step;
}

.step::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
}

.step-title {
  margin-bottom: var(--space-2);
  padding-top: 0.3rem;
}

.step p {
  max-width: 66ch;
}

.checkpoint {
  display: flex;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  font-size: var(--text-sm);
}

.checkpoint .icon-check {
  margin-top: 0.15rem;
  color: var(--success);
}

.checkpoint strong {
  margin-right: var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.safety-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.safety-list li {
  margin: 0;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}

.risk {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  margin-right: var(--space-2);
  padding: 0 var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.example {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}

.example > div {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.example dt {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.example dd {
  margin: var(--space-1) 0 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.related-list,
.task-skill-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-list li,
.task-skill-list li {
  margin: 0;
  border-top: 1px solid var(--border);
}

.related-list a,
.task-skill-list a {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  min-height: var(--target);
  padding: var(--space-2) 0;
  color: var(--text);
}

.related-list a:hover,
.task-skill-list a:hover {
  color: var(--accent-hover);
}

/* ---- Tasks and method ------------------------------------------------------ */

.task-grid {
  display: grid;
  gap: var(--space-6);
  padding-top: var(--space-6);
}

@media (min-width: 769px) {
  .task-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6) var(--space-7);
  }
}

.task-block {
  padding-top: var(--space-3);
  border-top: 2px solid var(--rule);
}

.task-block h2 {
  font-size: var(--text-lg);
}

.task-block h2 a {
  color: var(--text);
}

.task-section {
  padding-top: var(--space-5);
}

.other-title {
  margin-top: var(--space-6);
  font-size: var(--text-base);
}

.method {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-5);
}

.method-block {
  max-width: 80ch;
  padding: var(--space-5) 0;
  border-top: 1px solid var(--border);
}

.method-block:first-child {
  border-top: 0;
}

.method-block h2 {
  font-size: var(--text-lg);
}

@media (forced-colors: active) {
  .meter span,
  .env::before {
    forced-color-adjust: none;
    border-color: CanvasText;
  }

  .meter-1 span:nth-child(-n + 1),
  .meter-2 span:nth-child(-n + 2),
  .meter-3 span,
  .env-full::before {
    background: CanvasText;
  }

  .step::before,
  .env {
    border: 1px solid CanvasText;
  }
}

@media print {
  .finder-controls,
  .legend {
    display: none !important;
  }
}
