/*
 * icons.css: the HAFR icon family (line icons and feature tiles).
 *
 * Reads tokens.css and writes no colour of its own: every value below is a
 * token or a token mixed with transparency, so icons and tiles follow the
 * paper, night and instrument scopes by inheritance, with no theme selectors.
 *
 * Line icon (sprite):  <svg class="hf-icon" aria-hidden="true" focusable="false"><use href="/assets/icons/sprite.svg#hf-i-arrow-right"/></svg>
 * Line icon (inline):  the markup of icons/line/<name>.svg
 * Feature tile:        <span class="hf-ficon"> + the markup of icons/feature/<name>.svg + </span>
 *                      <span class="hf-ficon hf-ficon--seal"> on the one tile per view that wears the amber seal
 *
 * No glass: the tile is a calm solid surface (founder, 2026-11-27: "remove the
 * glass"). No backdrop blur, no gradient sheen, no prism facet. The tile SVG has
 * no ids, so it can be inlined any number of times on one page.
 *
 * Spec: knowledge/50-design-system/Icon System.md
 */

/* ── Line icons ─────────────────────────────────────────────────────────── */

.hf-icon {
  display: inline-block;
  flex: none;
  inline-size: 1em;
  block-size: 1em;
  vertical-align: -0.125em;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sizes: 16 dense rows and chips · 20 beside UI text and in buttons · 24 default · 32 largest interface size · 48 brand glyphs only */
.hf-icon--xs { inline-size: var(--hf-icon-xs); block-size: var(--hf-icon-xs); }
.hf-icon--sm { inline-size: var(--hf-icon-sm); block-size: var(--hf-icon-sm); }
.hf-icon--md { inline-size: var(--hf-icon-md); block-size: var(--hf-icon-md); }
.hf-icon--lg { inline-size: var(--hf-icon-lg); block-size: var(--hf-icon-lg); }
.hf-icon--xl { inline-size: var(--hf-icon-xl); block-size: var(--hf-icon-xl); }

/* Icons that encode reading direction mirror in Arabic; icons.json says which (mirrorInRtl). */
.hf-icon--dir:dir(rtl) { scale: -1 1; }
[dir="rtl"] .hf-icon--dir { scale: -1 1; }

/* The arrow inside an arrow-in-circle slides with the reading direction on hover. */
.hf-icon--nudge { transition: translate var(--hf-dur-2) var(--hf-ease-out); }
:is(a, button):is(:hover, :focus-visible) > * > .hf-icon--nudge,
:is(a, button):is(:hover, :focus-visible) > .hf-icon--nudge {
  translate: calc(var(--hf-move-arrow) * var(--hf-dir, 1)) 0;
}

@media (forced-colors: active) {
  .hf-icon { stroke: CanvasText; }
}

/* ── Feature tiles ──────────────────────────────────────────────────────── */

.hf-ficon {
  /* Recipe: a solid surface with a hairline edge, a 1 px top highlight inside
     the edge (it shows on night and instrument, where it reads as a machined
     bevel), a soft contact shadow, the glyph in ink with a 3 px line, and one
     seal square: ink at rest, amber on the one tile per view. */
  --hf-ficon-size: 64px;
  --hf-ficon-radius: var(--hf-radius-md);
  --hf-ficon-base: var(--hf-color-surface);
  --hf-ficon-edge: color-mix(in srgb, var(--hf-color-text-1) 11%, transparent);
  --hf-ficon-hi: var(--hf-glass-highlight);
  --hf-ficon-ink: var(--hf-color-text-1);
  --hf-ficon-seal: var(--hf-color-text-1);
  --hf-ficon-seal-edge: transparent;

  position: relative;
  display: inline-grid;
  flex: none;
  inline-size: var(--hf-ficon-size);
  block-size: var(--hf-ficon-size);
  border-radius: var(--hf-ficon-radius);
  box-shadow: var(--hf-shadow-1);
}
.hf-ficon > svg { display: block; inline-size: 100%; block-size: 100%; }

.hf-ficon .hf-fi-base { fill: var(--hf-ficon-base); stroke: var(--hf-ficon-edge); stroke-opacity: 1; }
.hf-ficon .hf-fi-hi { stroke: var(--hf-ficon-hi); stroke-opacity: 1; }
.hf-ficon .hf-fi-glyph { color: var(--hf-ficon-ink); }
.hf-ficon .hf-fi-seal { fill: var(--hf-ficon-seal); transition: fill var(--hf-dur-3) var(--hf-ease-out); }
.hf-ficon .hf-fi-seal-edge { stroke: var(--hf-ficon-seal-edge); stroke-opacity: 1; }

/* The amber seal: one tile per view (Design System Spec §2.4). */
.hf-ficon--seal {
  --hf-ficon-seal: var(--hf-color-seal);
  --hf-ficon-seal-edge: var(--hf-color-seal-edge);
}

/* In a group of cards the seal follows the pointer or the keyboard: the
   hovered or focused card takes it and the resting --seal tile gives it up,
   so a view never shows two. Mark the container with data-hf-seal-group;
   its direct children are the cards. */
[data-hf-seal-group]:has(> :is(:hover, :focus-within)) > :not(:hover, :focus-within) .hf-ficon {
  --hf-ficon-seal: var(--hf-color-text-1);
  --hf-ficon-seal-edge: transparent;
}
[data-hf-seal-group] > :is(:hover, :focus-within) .hf-ficon {
  --hf-ficon-seal: var(--hf-color-seal);
  --hf-ficon-seal-edge: var(--hf-color-seal-edge);
}

/* 48 px tiles for dense lists keep the recipe (the SVG radius scales to 10.5 px);
   below 48 px use the line icon instead. */
.hf-ficon--sm { --hf-ficon-size: 48px; --hf-ficon-radius: calc(var(--hf-radius-md) * 0.75); }

@media (prefers-contrast: more) {
  .hf-ficon { --hf-ficon-edge: var(--hf-color-line-input); }
}
@media (prefers-reduced-motion: reduce) {
  .hf-ficon .hf-fi-seal, .hf-icon--nudge { transition: none; }
}
@media (forced-colors: active) {
  .hf-ficon { box-shadow: none; }
  .hf-ficon .hf-fi-base { fill: Canvas; stroke: CanvasText; }
  .hf-ficon .hf-fi-hi { stroke: transparent; }
  .hf-ficon .hf-fi-glyph { color: CanvasText; }
  .hf-ficon .hf-fi-seal { fill: CanvasText; }
}
