/* ============================================
   ICON — Presentation layer for the offline SVG icon sprite
   Pairs with svg/icon.js (global: Icon) + svg/icon-sprite.js (global: IconSprite)
   ============================================
   Usage:
     <link rel="stylesheet" href="icon.css">
     <span data-icon="search"></span>
     <script>Icon.init();</script>

     <!-- or hand-written against the sprite, no JS at all -->
     <svg class="icn icn-lg icn-accent" aria-hidden="true"><use href="#icn-heart"/></svg>

   Variants (size):    .icn-xs .icn-sm .icn-md .icn-lg .icn-xl
   Variants (weight):  .icn-thin .icn-bold
   Variants (color):   .icn-accent .icn-muted .icn-ok .icn-warn .icn-danger
   Modifiers:          .icn-spin (loader-circle) .icn-tile (rounded chip)

   Tunables:
     --icn-size    box size, any length. Default 1.25em, so icons scale with the
                   text they sit next to instead of drifting out of rhythm.
     --icn-stroke  line weight, unitless. Default 2 (the set's native weight).
                   This is the icon-weight taste hook: 1.5 for editorial/light
                   aesthetics, 2.5 for brutalist/bold. It only works because the
                   sprite deliberately leaves stroke-width OFF the <symbol> — a
                   value set there is inherited by the <use> shadow content and
                   can never be overridden from here.
     --icn-tile-size, --icn-tile-bg   the .icn-tile chip
     --icn-spin-dur                   spinner period (continuous indicator, not a
                                      state transition — outside the blessed
                                      transition scale on purpose)

   Color: every glyph is stroked with currentColor, so an icon inherits the text
   color of whatever it sits in. The .icn-* color variants read palette tokens
   (--accent/--muted/--ok/--warn/--danger) with a standalone fallback.
   ============================================ */

.icn {
  inline-size: var(--icn-size, 1.25em);
  block-size: var(--icn-size, 1.25em);
  /* stroke-width lives here, not on the <symbol>, so --icn-stroke can theme
     the whole set. CSS beats the presentation attribute Icon.get() writes. */
  stroke-width: var(--icn-stroke, 2);
  color: inherit;
  flex: 0 0 auto;
  /* optical baseline correction for an icon sitting in a run of text */
  vertical-align: var(--icn-shift, -0.15em);
}

/* ── size scale ─────────────────────────────────────────────
   em-based so icons track their type size. Override --icn-size
   inline for a fixed pixel box: style="--icn-size:32px". */
.icn-xs { --icn-size: 0.875em; }
.icn-sm { --icn-size: 1em; }
.icn-md { --icn-size: 1.25em; }
.icn-lg { --icn-size: 1.5em; }
.icn-xl { --icn-size: 2em; }

/* ── weight ─────────────────────────────────────────────────
   Lucide draws at 2. Below ~1.25 hairlines disappear on non-retina
   displays; above ~2.75 the 24-grid counters start to close up. */
.icn-thin { --icn-stroke: 1.5; }
.icn-bold { --icn-stroke: 2.5; }

/* ── color ──────────────────────────────────────────────────
   Palette tokens with a fallback, so a bare copy-paste still renders. */
.icn-accent { color: var(--accent, #7c5cff); }
.icn-muted  { color: var(--muted, #8a8f98); }
.icn-ok     { color: var(--ok, #34d399); }
.icn-warn   { color: var(--warn, #fbbf24); }
.icn-danger { color: var(--danger, #f87171); }

/* ── rounded chip, for feature grids and list rows ──────────
   Sized off its own token so the glyph inside keeps using --icn-size. */
.icn-tile {
  display: inline-grid;
  place-items: center;
  inline-size: var(--icn-tile-size, 2.5em);
  block-size: var(--icn-tile-size, 2.5em);
  border-radius: var(--radius, 12px);
  background: var(--icn-tile-bg, color-mix(in oklab, currentColor 12%, transparent));
  color: var(--accent, #7c5cff);
}
.icn-tile > .icn { --icn-size: 1.25em; }
.icn-tile-round { border-radius: 50%; }

/* ── busy indicator ─────────────────────────────────────────
   Pair with the loader-circle glyph. A continuous progress indicator, so its
   period is its own token rather than a blessed transition duration. */
@keyframes icn-spin { to { transform: rotate(1turn); } }
@keyframes icn-breathe { to { opacity: 0.45; } }

.icn-spin {
  transform-origin: 50% 50%;
  animation: icn-spin var(--icn-spin-dur, 800ms) linear infinite;
}

/* Rotation is the classic vestibular trigger. Don't drop the affordance —
   swap it for a non-moving one, so "busy" is still communicated. */
@media (prefers-reduced-motion: reduce) {
  .icn-spin {
    animation: icn-breathe 480ms ease-in-out infinite alternate;
  }
}
