/* The hardware guide: /almanac/hardware, /almanac/hardware/{slug}. Uses the tokens in kj.css
   (loaded by every page), so both colour schemes follow; there are no literal colours. */

.hw-page { padding-top: 2rem; padding-bottom: 3rem; }
.hw-page [hidden] { display: none !important; }

/* ---------- shared bits ---------- */
.hw-cost { letter-spacing: 0.04em; font-weight: 600; color: var(--ink); white-space: nowrap; }
.hw-dim { color: var(--line-strong); }


.hw-badge {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.hw-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0; padding: 0; }
.hw-chip, .hw-chips--lg li {
  padding: 0.05rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: transparent;
}
.hw-chip--use { border-style: dashed; }
.hw-chips--lg li { font-size: 0.9rem; padding: 0.2rem 0.75rem; background: var(--surface); color: var(--ink); }
.hw-small { font-size: 0.88rem; color: var(--ink-soft); }

/* ---------- index ---------- */
.hw-jump { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.hw-jump a {
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.hw-jump a:hover { border-color: var(--accent); }

.hw-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 1rem 0 0.5rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.hw-filter[hidden] { display: none; }
.hw-field { min-width: 8rem; }
.hw-field--grow { flex: 1 1 14rem; }
.hw-field--check { min-width: 0; align-self: flex-end; }
.hw-field label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 0.25rem; }
.hw-field input[type="search"], .hw-field select {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
/* #702: the species field is kj-widgets' `choice_field` now, not a bare `<select>` — its
   own kj.css styling (bold legend, 20px bottom margin) is sized for a standalone form, not
   this compact flex filter bar, so it's overridden to match the other `.hw-field`s here. */
.hw-field .kj-field,
.hw-field .kj-choice { margin: 0; }
.hw-field .kj-field label,
.hw-field .kj-choice legend {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 0.25rem;
}
.hw-field .kj-field input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.hw-reset { padding: 0.45rem 1rem; font-size: 0.9rem; }
.hw-filter-note { flex: 1 1 100%; margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
.hw-count { margin: 0.5rem 0 1rem; font-size: 0.9rem; color: var(--ink-soft); }

.hw-kind-block { margin-top: 2.25rem; scroll-margin-top: var(--kj-anchor-offset, 5rem); }
.hw-kind-block > h2 { border-bottom: 2px solid var(--line); padding-bottom: 0.3rem; }
.hw-n { font-family: var(--font-body); font-size: 0.55em; font-weight: 500; color: var(--ink-faint); }
.hw-group { margin: 1.25rem 0 1.75rem; }
.hw-group > h3 { color: var(--ink-soft); margin-bottom: 0.6rem; }

.hw-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.hw-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.5fr);
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.hw-row:hover, .hw-row:focus-within { border-color: var(--accent); box-shadow: var(--shadow); }
.hw-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.6rem; }
.hw-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.08rem;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
}
/* The whole row is the click target: the name's link stretches over it. */
.hw-name::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.hw-name:hover { text-decoration: underline; }
.hw-name:focus-visible { outline: none; }
.hw-name:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 2px; }
.hw-sum { margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--ink-soft); }
.hw-flag { margin: 0.4rem 0 0; font-size: 0.82rem; font-weight: 600; }
.hw-flag--avoid { color: var(--danger); }
.hw-flag--fit { color: var(--accent); }
.hw-flag--avoid::before { content: "\26A0\FE0E  "; }
.hw-flag--fit::before { content: "\2713  "; }

.hw-side { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.hw-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.2rem, 1fr)); gap: 0.4rem 0.8rem; }
.hw-stat { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--ink); }
.hw-stat-l { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
.hw-note { margin-top: 2.5rem; font-size: 0.88rem; color: var(--ink-soft); max-width: 46rem; }

/* ---------- detail ---------- */
.hw-crumbs { font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 1rem; }
.hw-title h1 { margin-bottom: 0.15em; }
.hw-lede { font-size: 1.1rem; color: var(--ink-soft); margin: 0 0 0.75rem; max-width: 46rem; }
.hw-badges { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; margin: 0 0 1.5rem; padding: 0; }
.hw-badge-stat { font-size: 0.9rem; color: var(--ink); }

.hw-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  grid-template-areas: "hero facts" "main facts";
  gap: 0 2rem;
  align-items: start;
}
.hw-hero { grid-area: hero; }
.hw-hero:empty { display: none; }
.hw-facts { grid-area: facts; }
.hw-main-col { grid-area: main; min-width: 0; }
@media (max-width: 860px) {
  .hw-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hero" "facts" "main"; }
}

.hw-figure { margin: 0 0 1.5rem; }
.hw-figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 28rem;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
/* Rendered illustrations: transparent WebP on the same card, light/dark pair toggled like the
   glossary's drawings (catalogue.css .kj-glossary-model). */
.hw-drawing { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.hw-drawing img { border: 0; border-radius: 0; background: transparent; max-height: none; }
.hw-drawing img.hw-dark { display: none; }
:root[data-theme="dark"] .hw-drawing img.hw-light { display: none; }
:root[data-theme="dark"] .hw-drawing img.hw-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hw-drawing img.hw-light { display: none; }
  :root:not([data-theme="light"]) .hw-drawing img.hw-dark { display: block; }
}
.hw-figure figcaption { margin-top: 0.4rem; font-size: 0.85rem; color: var(--ink-soft); }
.hw-credit { color: var(--ink-faint); }
.hw-credit a { color: var(--ink-soft); }

.hw-facts {
  padding: 1rem 1.1rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.hw-facts h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.hw-facts h3 { margin-top: 1rem; font-size: 1rem; }
.hw-facts dl { margin: 0; display: grid; grid-template-columns: minmax(5.5rem, auto) minmax(0, 1fr); gap: 0.45rem 0.9rem; font-size: 0.92rem; }
.hw-facts dt { color: var(--ink-faint); font-weight: 600; }
.hw-facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.hw-facts dd small { color: var(--ink-soft); font-size: 0.82rem; }

.hw-toc { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.5rem; }
.hw-toc a {
  font-size: 0.85rem;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  text-decoration: none;
}
.hw-toc a:hover { border-color: var(--accent); color: var(--ink); }

.hw-body h2, .hw-styles h2, .hw-species h2, .hw-designs h2, .hw-gallery h2, .hw-sources h2 {
  font-size: 1.4rem;
  margin: 1.8rem 0 0.5rem;
  scroll-margin-top: var(--kj-anchor-offset, 5rem);
}
.hw-body h3 { margin: 1.2rem 0 0.4rem; }
.hw-body > h2:first-child { margin-top: 0; }
.hw-body ul, .hw-body ol { color: var(--ink-soft); padding-left: 1.3rem; margin: 0 0 1em; }
.hw-body li { margin-bottom: 0.3em; }
.hw-body strong { color: var(--ink); }
.hw-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 0 0 1em; }
.hw-body th, .hw-body td { padding: 0.35rem 0.7rem; border: 1px solid var(--line); text-align: left; color: var(--ink-soft); }
.hw-body code { font-size: 0.9em; background: var(--surface); padding: 0.05em 0.3em; border-radius: 4px; }
.hw-body { overflow-wrap: break-word; }


.hw-species--avoid .hw-chips--lg li { border-color: var(--danger); }
.hw-chips--lg a, .hw-chips--lg a:hover { color: var(--ink); }
.hw-badge--slide, .hw-badge--catch, .hw-badge--lock, .hw-badge--tabletop { background: var(--accent-2); color: var(--accent-2-ink); }
.hw-badge--screw, .hw-badge--nail, .hw-badge--knockdown, .hw-badge--bracket, .hw-badge--support, .hw-badge--caster {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong);
}
.hw-chip--material { background: var(--surface-2); }
.hw-sizes { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; color: var(--ink-soft); }
.hw-sizes li { margin-bottom: 0.3rem; overflow-wrap: anywhere; }
.hw-designs code { font-size: 0.9em; background: var(--surface); padding: 0.05em 0.3em; border-radius: 4px; }
.hw-sources ul { margin: 0; padding-left: 1.2rem; font-size: 0.9rem; color: var(--ink-soft); }
.hw-sources li { overflow-wrap: anywhere; margin-bottom: 0.25rem; }
.hw-honesty {
  margin-top: 2rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-left: 4px solid var(--accent-2);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.hw-prevnext {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.hw-prevnext a { display: flex; flex-direction: column; max-width: 48%; text-decoration: none; color: var(--ink); }
.hw-prevnext a span { font-size: 0.8rem; color: var(--ink-faint); }
.hw-prevnext a strong { font-family: var(--font-heading); font-weight: 600; }
.hw-prevnext a:hover strong { text-decoration: underline; }
.hw-next { margin-left: auto; text-align: right; }

@media (max-width: 760px) {
  .hw-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .hw-field { flex: 1 1 8rem; }
  .hw-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
