/* =========================================================================
   Cabinhub News — icon set sizing and placement (N3-DESIGN)

   One stroke set, defined in frontend/js/icons.js (Lucide v1.70.0, ISC plus
   MIT for the Feather-derived glyphs; see that file's header). This file
   owns only how a glyph sits on the page: size, optical alignment with text,
   and the tap target of an icon-only control. It draws nothing and loads
   nothing.

   Colour is never set here. Every glyph strokes with currentColor, so an
   icon inherits the text colour of its context and both themes work with no
   extra rule. Only these tokens are touched, always with a fallback:
     --fg-3 (muted) · --accent · --focus · --tap
   ========================================================================= */

/* --------------------------------------------------------------- sizing --
   .icon is the base and the md default (18px, the size of the theme-switch
   marks already in the header). Add a modifier to move one step. */
.icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: none;
  /* Optically centred on the x-height, not the baseline: an 18px glyph next
     to a 16-17px line sits ~2px low on the baseline. -0.125em is the shift
     that centres it in both en and zh runs. */
  vertical-align: -0.125em;
  /* Belt and braces: the SVG element carries these too, so a glyph built by
     CBNIcons.icon() renders correctly even before this file loads. */
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm { width: 14px; height: 14px; vertical-align: -0.1em; }
.icon--md { width: 18px; height: 18px; }
.icon--lg { width: 24px; height: 24px; vertical-align: -0.15em; }

/* A glyph that carries meaning alone (a link out, an RSS feed) must not be
   the only label: pair it with visually hidden text or an aria-label. */
.icon--muted { color: var(--fg-3, var(--ink-faint, #6D6259)); }
.icon--accent { color: var(--accent, #BC3E0D); }

/* ------------------------------------------------------- text alignment --
   In running text a glyph needs a hair of air, or the next word touches the
   stroke. Scoped to text contexts, and to a glyph that has siblings, so an
   icon-only control is never nudged off centre. */
p > .icon:first-child:not(:only-child),
a > .icon:first-child:not(:only-child) { margin-inline-end: 0.35em; }
p > .icon:last-child:not(:only-child),
a > .icon:last-child:not(:only-child) { margin-inline-start: 0.35em; margin-inline-end: 0; }

/* Inside a flex control the flex gap owns the spacing. */
.chip > .icon,
.btn > .icon,
button > .icon { margin: 0; }

/* ----------------------------------------------------------- tap target --
   Han's rule: one consistent set, and every control touchable. The TARGET
   grows to 44px; the drawing stays 18px. The SVG must never carry the
   min-size itself or the glyph would scale up with the box. */
.button-icon,
button:has(> .icon:only-child),
a:has(> .icon:only-child) {
  min-width: var(--tap, 44px);
  min-height: var(--tap, 44px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Focus is the reader's, not ours: never remove the ring, only draw it in
   the one focus colour. */
.button-icon:focus-visible,
button:has(> .icon:only-child):focus-visible,
a:has(> .icon:only-child):focus-visible {
  outline: 2px solid var(--focus, #D64221);
  outline-offset: 2px;
  border-radius: 6px;
}

/* The placeholder is only a mount point; it must not reserve its own box. */
[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
