/*
 * i-Swipe icon system (Lucide icons drawn by Core\Icon / icon()). Guide: docs/ICONS.md.
 * Loaded by every app layout (views/layouts/_theme.php), the super admin layout and the public website.
 * Every rule is scoped to .isi* classes so older page styles (.ic, .ico, .icon) are untouched.
 */
:root {
  /* sizes */
  --isi-xs: 12px; --isi-sm: 14px; --isi-md: 16px; --isi-lg: 20px; --isi-xl: 24px; --isi-2xl: 32px; --isi-3xl: 40px;
  /* stroke widths (Core\Icon::STROKE*) */
  --isi-stroke: 1.75; --isi-stroke-sm: 2; --isi-stroke-lg: 1.5;
  /* gap between an icon and its label */
  --isi-gap: 6px; --isi-gap-lg: 8px;
  /* icon-only buttons */
  --isi-btn: 32px; --isi-btn-sm: 28px; --isi-btn-touch: 40px; --isi-btn-radius: var(--ui-r-xs, 8px);
  /* colours: follow the app theme (tokens.css / theme.css), with brand fallbacks for pages without them */
  --isi-brand: var(--ui-accent, var(--brand-primary, #2563EB));
  --isi-navy: #0A1F44;
  --isi-muted: var(--ui-muted, #556274);
  --isi-faint: var(--ui-faint, #667085);
  --isi-good: var(--ui-good, #15803D);
  --isi-warn: var(--ui-warn, #B54708);
  --isi-bad: var(--ui-bad, #B42318);
  --isi-info: var(--ui-info, #175CD3);
  --isi-hover-bg: var(--ui-wash, #F1F5F9);
  --isi-active-bg: var(--ui-track, #E2E8F0);
  --isi-ring: 0 0 0 2px var(--ui-paper, #fff), 0 0 0 4px #2563EB;
}
:root[data-theme="dark"] {
  --isi-navy: #C7D7F5;              /* navy text would vanish on a dark card: use a light navy tint */
  --isi-hover-bg: rgba(255, 255, 255, .06);
  --isi-active-bg: rgba(255, 255, 255, .1);
  --isi-ring: 0 0 0 2px var(--ui-paper, #141E33), 0 0 0 4px #60A5FA;
}

/* The icon itself: sits on the text's middle, never shrinks in flex rows, takes the text colour */
.isi {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: -0.125em;          /* lines a 16px icon up with 13-15px text: no baseline wobble */
  stroke: currentColor;
  overflow: visible;
  pointer-events: none;              /* clicks land on the button or link around it */
}
.isi[role="img"] { pointer-events: auto; }   /* labelled icons keep their tooltip */
.isi-xs  { width: var(--isi-xs);  height: var(--isi-xs); }
.isi-sm  { width: var(--isi-sm);  height: var(--isi-sm); }
.isi-md  { width: var(--isi-md);  height: var(--isi-md); }
.isi-lg  { width: var(--isi-lg);  height: var(--isi-lg); }
.isi-xl  { width: var(--isi-xl);  height: var(--isi-xl); }
.isi-2xl { width: var(--isi-2xl); height: var(--isi-2xl); }
.isi-3xl { width: var(--isi-3xl); height: var(--isi-3xl); }

/* Colour utilities (put them on the icon or on a parent) */
.isi-muted { color: var(--isi-muted); }
.isi-faint { color: var(--isi-faint); }
.isi-brand { color: var(--isi-brand); }
.isi-navy  { color: var(--isi-navy); }
.isi-good  { color: var(--isi-good); }
.isi-warn  { color: var(--isi-warn); }
.isi-bad   { color: var(--isi-bad); }
.isi-info  { color: var(--isi-info); }

/* Spinning loader: icon('loading', 'sm', ['class' => 'isi-spin']) */
@keyframes isi-spin { to { transform: rotate(360deg); } }
.isi-spin { animation: isi-spin 0.9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .isi-spin { animation-duration: 2.4s; } }

/* Icon + label: <span class="isi-label"><?= icon('leave') ?>Leave</span> (also for links and buttons) */
.isi-label { display: inline-flex; align-items: center; gap: var(--isi-gap); min-width: 0; }
.isi-label.isi-gap-lg { gap: var(--isi-gap-lg); }

/* Icon-only button: <button type="button" class="isi-btn" aria-label="Delete" title="Delete"><?= icon('delete') ?></button> */
.isi-btn {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: var(--isi-btn); height: var(--isi-btn); min-width: var(--isi-btn);
  padding: 0; margin: 0; border: 1px solid transparent; border-radius: var(--isi-btn-radius);
  background: transparent; color: var(--isi-muted);
  font: inherit; line-height: 1; cursor: pointer; text-decoration: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.isi-btn:hover { background: var(--isi-hover-bg); color: var(--ui-ink, #0F172A); }
.isi-btn:active { background: var(--isi-active-bg); }
.isi-btn:focus { outline: none; }
.isi-btn:focus-visible { outline: none; box-shadow: var(--isi-ring); }
.isi-btn:disabled, .isi-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; background: transparent; }
.isi-btn.is-outline { border-color: var(--ui-line, #E4E7EC); background: var(--ui-paper, #fff); }
.isi-btn.is-danger:hover { color: var(--isi-bad); background: var(--ui-bad-bg, #FEF3F2); }
.isi-btn.is-brand { color: var(--isi-brand); }
.isi-btn.is-sm { width: var(--isi-btn-sm); height: var(--isi-btn-sm); min-width: var(--isi-btn-sm); }
:root[data-theme="dark"] .isi-btn:hover { color: var(--ui-ink, #F1F5F9); }
:root[data-theme="dark"] .isi-btn.is-outline { border-color: var(--ui-line-3, #36455F); background: transparent; }

/* Touch screens: icon-only buttons grow to a 40px target */
@media (pointer: coarse), (max-width: 767px) {
  .isi-btn, .isi-btn.is-sm { width: var(--isi-btn-touch); height: var(--isi-btn-touch); min-width: var(--isi-btn-touch); }
}

/* Round tinted icon "chip" for cards, empty states and notifications */
.isi-chip {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--ui-accent-soft, #EFF6FF); color: var(--isi-brand);
}
.isi-chip.is-lg { width: 64px; height: 64px; border-radius: 16px; }
.isi-chip.is-good { background: var(--ui-good-bg, #ECFDF3); color: var(--isi-good); }
.isi-chip.is-warn { background: var(--ui-warn-bg, #FFFAEB); color: var(--isi-warn); }
.isi-chip.is-bad  { background: var(--ui-bad-bg, #FEF3F2);  color: var(--isi-bad); }
.isi-chip.is-muted { background: var(--ui-slate-bg, #F1F5F9); color: var(--isi-muted); }

/* Windows high contrast: keep icons visible */
@media (forced-colors: active) {
  .isi { stroke: CanvasText; }
  .isi-btn:focus-visible { outline: 2px solid Highlight; }
}
