/* ── Bridge — variables locales complémentaires aux tokens SireneFlux ─────── */
/*
 * Ce fichier s'appuie sur css/theme.css (chargé en amont dans le HTML).
 * Les variables SireneFlux disponibles :
 *   couleurs : --bg-primary/secondary/tertiary/elevated, --surface, --surface-hover/active
 *              --border-subtle/default/strong
 *              --text-primary/secondary/tertiary/inverse
 *              --accent, --accent-hover, --accent-soft
 *              --success, --warning, --danger, --danger-soft
 *   typo     : --font-sans, --font-mono, --fs-xs/sm/md/lg/xl
 *   rayons   : --radius-sm/md/lg/xl
 *   ombres   : --shadow-xs/sm/md/lg
 *   transitions : --t-fast/base/slow
 */
:root {
  /* Inter est chargé via Google Fonts dans ce fichier HTML */
  --font-sans: 'Inter', 'Helvetica Neue', Arial, sans-serif;

  /* Tailles de texte étendues (hero + stats) */
  --text-xl-fluid: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl-fluid: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);

  /* Coin plein (non défini dans theme.css) */
  --radius-full: 9999px;

  /* Formes Mermaid */
  --shape-bg: var(--bg-tertiary);
  --shape-stroke: var(--border-strong);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.6;
}
img, svg { display: block; max-width: 100%; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
a, button, [role='button'], input {
  transition: color var(--t-base), background var(--t-base), border-color var(--t-base),
              box-shadow var(--t-base), opacity var(--t-base);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-sm); }
::selection { background: var(--accent-soft); }

/* ── Header ────────────────────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
  height: 60px; display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 0.625rem; text-decoration: none; color: var(--text-primary); }
.logo-text { font-weight: 700; font-size: var(--fs-sm); letter-spacing: -0.02em; }
.logo svg { flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.badge {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  padding: 0.2em 0.55em; border-radius: var(--radius-full);
  background: var(--bg-tertiary); color: var(--accent);
  border: 1px solid var(--border-default); font-weight: 600;
}
.theme-toggle {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); background: var(--bg-secondary);
  border: 1px solid var(--border-default);
}
.theme-toggle:hover { color: var(--text-primary); background: var(--surface-hover); }

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: clamp(3rem, 8vw, 6rem) clamp(1rem, 4vw, 2.5rem) clamp(2rem, 5vw, 4rem);
}
.hero-title {
  font-size: var(--text-2xl-fluid); font-weight: 800; letter-spacing: -0.04em;
  line-height: 1.05; margin-bottom: 0.75rem;
  font-family: var(--font-sans);
}
.accent { color: var(--accent); }
.hero-sub {
  font-size: var(--fs-md); color: var(--text-secondary);
  max-width: 52ch; margin: 0 auto 2rem;
}

.stats-row { display: flex; align-items: center; justify-content: center; gap: 1.5rem; }
.stat { text-align: center; }
.stat-num {
  display: block; font-size: var(--text-xl-fluid); font-weight: 800;
  color: var(--text-primary); letter-spacing: -0.03em; line-height: 1;
}
.stat-label {
  font-size: var(--fs-xs); color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.stat-sep { width: 1px; height: 40px; background: var(--border-subtle); }

/* ── Controls ──────────────────────────────────────────────────────────────── */
.controls {
  max-width: 1280px; margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 1.5rem;
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
}
.search-wrap {
  position: relative; display: flex; align-items: center;
  flex: 1; min-width: 240px; max-width: 380px;
}
.search-icon {
  position: absolute; left: 0.875rem; color: var(--text-tertiary);
  flex-shrink: 0; pointer-events: none;
}
#search {
  width: 100%; padding: 0.625rem 2.5rem 0.625rem 2.5rem;
  border-radius: var(--radius-lg); border: 1.5px solid var(--border-default);
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: var(--fs-sm); font-family: var(--font-sans);
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#search::placeholder { color: var(--text-tertiary); }
kbd {
  position: absolute; right: 0.75rem;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  color: var(--text-tertiary); background: var(--bg-tertiary);
  border: 1px solid var(--border-default); border-radius: 4px; padding: 0.15em 0.4em;
  pointer-events: none;
}

.filter-group { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.filter-btn {
  padding: 0.375rem 0.875rem; border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.01em;
  border: 1.5px solid var(--border-default);
  background: var(--bg-secondary); color: var(--text-secondary);
}
.filter-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.filter-btn.active { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }

.view-toggle { display: flex; gap: 0.25rem; margin-left: auto; }
.view-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); color: var(--text-secondary);
  border: 1.5px solid var(--border-default); background: var(--bg-secondary);
}
.view-btn:hover { color: var(--text-primary); background: var(--surface-hover); }
.view-btn.active {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-soft);
}

.results-count {
  max-width: 1280px; margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 0.75rem;
  font-size: var(--fs-xs); color: var(--text-secondary); font-weight: 500;
}

/* ── Grid ──────────────────────────────────────────────────────────────────── */
.shapes-grid {
  max-width: 1280px; margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 4rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.shapes-grid.view-list {
  display: flex; flex-direction: column; gap: 0.5rem;
}

/* ── Shape Card ─────────────────────────────────────────────────────────────── */
.shape-card {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.shape-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.shape-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card-preview {
  background: var(--bg-tertiary);
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}
.card-preview svg { width: 100%; max-width: 140px; height: auto; }

.card-body { padding: 1rem; }
.card-header-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.5rem;
}
.card-name { font-size: var(--fs-sm); font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.card-cat {
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em;
  padding: 0.2em 0.55em; border-radius: var(--radius-full);
  white-space: nowrap; flex-shrink: 0;
}
.card-syntax {
  display: block; font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm); padding: 0.25em 0.5em;
  margin-bottom: 0.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-desc { font-size: var(--fs-xs); color: var(--text-secondary); line-height: 1.5; }

/* List view overrides */
.view-list .shape-card {
  display: flex; flex-direction: row; align-items: center;
  border-radius: var(--radius-lg);
}
.view-list .card-preview {
  border-bottom: none; border-right: 1px solid var(--border-subtle);
  padding: 0.75rem 1rem; flex-shrink: 0; min-width: 100px;
}
.view-list .card-preview svg { max-width: 80px; }
.view-list .card-body { padding: 0.75rem 1rem; flex: 1; }
.view-list .card-desc { display: none; }

/* ── Category colors ────────────────────────────────────────────────────────── */
.cat-basic    { background: #eef2ff; color: #4338ca; }
.cat-process  { background: #ecfdf5; color: #059669; }
.cat-data     { background: #fffbeb; color: #b45309; }
.cat-decision { background: #fdf2f8; color: #9d174d; }
.cat-terminal { background: #f5f3ff; color: #7c3aed; }
.cat-document { background: #ecfeff; color: #0e7490; }
.cat-storage  { background: #f8fafc; color: #475569; }
.cat-misc     { background: #f0fdf4; color: #15803d; }

[data-theme='dark'] .cat-basic    { background: rgba(99,102,241,0.15); color: #a5b4fc; }
[data-theme='dark'] .cat-process  { background: rgba(16,185,129,0.12); color: #6ee7b7; }
[data-theme='dark'] .cat-data     { background: rgba(245,158,11,0.12); color: #fcd34d; }
[data-theme='dark'] .cat-decision { background: rgba(236,72,153,0.12); color: #f9a8d4; }
[data-theme='dark'] .cat-terminal { background: rgba(139,92,246,0.12); color: #c4b5fd; }
[data-theme='dark'] .cat-document { background: rgba(6,182,212,0.12); color: #67e8f9; }
[data-theme='dark'] .cat-storage  { background: rgba(148,163,184,0.1); color: #94a3b8; }
[data-theme='dark'] .cat-misc     { background: rgba(34,197,94,0.12); color: #86efac; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  max-width: 400px; margin: 4rem auto; text-align: center;
  color: var(--text-secondary); padding: 0 1.5rem;
}
.empty-state svg { margin: 0 auto 1rem; opacity: 0.4; }
.empty-state p { font-size: var(--fs-md); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: oklch(0 0 0 / 0.65);
  backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 250ms ease;
}
.modal.open .modal-backdrop { opacity: 1; }

.modal-panel {
  position: relative; z-index: 1;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1), opacity 250ms ease;
}
.modal.open .modal-panel { transform: translateY(0) scale(1); opacity: 1; }

.modal-header {
  display: flex; gap: 1.25rem; align-items: flex-start;
  padding: 1.5rem; border-bottom: 1px solid var(--border-subtle);
}
.modal-preview {
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg); padding: 1rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 120px; height: 100px;
  border: 1px solid var(--border-default);
}
.modal-preview svg { width: 100%; height: auto; }
.modal-meta { flex: 1; }
.modal-title {
  font-size: var(--fs-lg); font-weight: 800;
  letter-spacing: -0.02em; margin-bottom: 0.375rem;
}
.modal-desc {
  font-size: var(--fs-sm); color: var(--text-secondary);
  line-height: 1.6; margin-bottom: 0.75rem;
}
.modal-tags { display: flex; flex-wrap: wrap; gap: 0.375rem; }

.tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 0.2em 0.6em; border-radius: var(--radius-full); text-transform: uppercase;
}
.tag-new {
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); color: var(--text-secondary);
  background: var(--bg-tertiary); border: 1px solid var(--border-default);
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text-primary); background: var(--surface-active); }

.modal-body { padding: 1.5rem; }

/* ── Code section ─────────────────────────────────────────────────────────── */
.code-section { margin-bottom: 1.5rem; }
.code-tabs {
  display: flex; gap: 0.25rem; margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.5rem;
}
.code-tab {
  font-size: var(--fs-xs); font-weight: 600; padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md); color: var(--text-secondary);
  border: 1px solid transparent;
}
.code-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.code-tab.active {
  background: var(--bg-tertiary); color: var(--accent);
  border-color: var(--accent);
}

.code-block-wrap { position: relative; }
pre {
  background: var(--bg-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  padding: 1rem 1rem 1rem 1.25rem;
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.7;
  color: var(--text-primary); overflow-x: auto; white-space: pre;
}
.copy-btn {
  position: absolute; top: 0.625rem; right: 0.625rem;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-secondary);
  background: var(--bg-tertiary); border: 1px solid var(--border-default);
  opacity: 0.7; transition: opacity var(--t-base);
}
.copy-btn:hover { opacity: 1; color: var(--text-primary); }

/* ── Alias section ──────────────────────────────────────────────────────── */
.alias-title {
  font-size: var(--fs-sm); font-weight: 700;
  margin-bottom: 0.625rem; color: var(--text-secondary);
}
.alias-list { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.alias-chip {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  padding: 0.25em 0.6em; border-radius: var(--radius-sm);
  background: var(--bg-tertiary); color: var(--text-secondary);
  border: 1px solid var(--border-default);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  text-align: center; padding: 2.5rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-xs); color: var(--text-tertiary);
}
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; color: var(--accent-hover); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .stats-row { gap: 1rem; }
  .controls { flex-direction: column; align-items: stretch; }
  .search-wrap { max-width: 100%; }
  .view-toggle { margin-left: 0; }
  .shapes-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .modal-header { flex-direction: column; }
  .modal-preview { width: 100%; height: 120px; }
  kbd { display: none; }
}

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.shape-card { animation: fadeInUp 220ms ease both; }

@media (prefers-reduced-motion: reduce) {
  .shape-card { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

/* ── Mode intégré dans SireneFlux (iframe) ────────────────────────────────── */
html.is-iframe .header { display: none; }
html.is-iframe .footer { display: none; }
html.is-iframe body { min-height: 100%; }
html.is-iframe .hero {
  padding-top: clamp(1.5rem, 3vw, 2.5rem);
  padding-bottom: clamp(1rem, 2vw, 1.75rem);
}
html.is-iframe .hero-title { font-size: var(--fs-xl); }
html.is-iframe .shapes-grid { padding-bottom: 2.5rem; }
