/* ==========================================================================
   USINE LOGICIELLE AI-NATIVE (ressources/usine-logicielle-ai-native.html)
   Styles propres à cette page (sortis du <style> inline : CSP sans 'unsafe-inline',
   cf. CLAUDE.md règle 9). Couleurs dérivées uniquement des tokens odinn.* via
   var(--odinn-*) (projetés dans tailwind-source.css, règle 2) — aucun hex en dur.
   ========================================================================== */

:root {
  --radius: 1.25rem;
  --radius-sm: 0.75rem;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t: 0.22s;

  --bg: var(--odinn-bg);
  --surface: var(--odinn-card);
  --surface2: color-mix(in srgb, var(--odinn-bg) 55%, var(--odinn-card));
  --surface3: var(--odinn-accent-light);
  --text: var(--odinn-text);
  --text-muted: var(--odinn-subtext);
  --text-dim: var(--odinn-muted);
  --border: var(--odinn-border);
  --border-soft: color-mix(in srgb, var(--odinn-border) 60%, var(--odinn-card));
  --accent: var(--odinn-accent);
  --accent-fg: var(--odinn-card);
  --accent-dim: color-mix(in srgb, var(--odinn-accent) 12%, transparent);
  /* Texte posé sur --accent-dim : accent assombri pour garder un contraste >= 4.5:1 */
  --accent-on-dim: var(--odinn-accent-hover);
  --accent2: var(--odinn-gold);
  --accent2-dim: color-mix(in srgb, var(--odinn-gold) 14%, transparent);
  --success: var(--odinn-success);
  --success-dim: color-mix(in srgb, var(--odinn-success) 10%, transparent);
  --warning: var(--odinn-warning);
  --warning-dim: color-mix(in srgb, var(--odinn-warning) 10%, transparent);
  --purple: var(--odinn-accent-hover);
  --purple-dim: color-mix(in srgb, var(--odinn-accent-hover) 12%, transparent);
  --neutral: var(--odinn-muted);
  --neutral-dim: color-mix(in srgb, var(--odinn-muted) 10%, transparent);
  --shadow: 0 10px 34px rgba(35, 30, 20, 0.08);
  --shadow-sm: 0 4px 14px rgba(35, 30, 20, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Espace pour le header Odinn fixe (~5.5rem) */
  padding-top: 5.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--accent-dim); color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}


/* ===== LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 1rem 1.5rem 4rem;
  flex: 1 0 auto;
}

/* ===== MENU (carte collante, pas une colonne pleine hauteur) ===== */
aside {
  position: sticky;
  top: 6.5rem;
}
.plan-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 7.5rem);
  overflow-y: auto;
  padding: 0.9rem 0.6rem;
}
.plan-menu::-webkit-scrollbar { width: 8px; }
.plan-menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.plan-menu > summary { display: none; }
/* Vue d'ensemble : le schéma tient lieu de sommaire, le menu n'apparaît que dans le détail */
.layout:has(#view-diagram.active) { grid-template-columns: minmax(0, 1fr); }
.layout:has(#view-diagram.active) aside { display: none; }

.plan-menu a {
  display: block;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.35;
  text-decoration: none;
  transition: background var(--t) var(--ease);
}
.plan-menu a:hover { background: var(--surface2); color: var(--text); }
.plan-menu a.active { background: var(--accent-dim); color: var(--accent-on-dim); font-weight: 600; }
.plan-menu .menu-home { font-weight: 600; color: var(--text); }

.plan-menu ul { list-style: none; padding-left: 0.7rem; }
/* Les quatre couches au même niveau : même taille, même graisse, cliquables ou non */
.plan-menu .menu-couche {
  margin-top: 0.6rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

/* ===== MAIN ===== */
main { min-width: 0; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.79rem;
  color: var(--text-dim);
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb:empty { display: none; }
.breadcrumb .sep { opacity: 0.5; }
.breadcrumb .current { color: var(--text-muted); font-weight: 500; }

.view { display: none; }
.view.active { display: block; animation: fadeUp 0.32s var(--ease); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== HERO (resserré) ===== */
.hero {
  max-width: 760px;
  margin: 0 auto 0.25rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.3rem, 2.4vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.35rem;
}
.hero p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ===== VUE D'ENSEMBLE : plans à gauche, fonctions transverses en colonne à droite ===== */
.stack {
  display: grid;
  /* Colonne fonctions transverses calculée pour que ses cases aient la largeur de celles des plans
     (marges .couche 0.55rem, .plane 0.9rem, écarts 0.55rem / 0.4rem, bordures 1px) */
  grid-template-columns: minmax(0, 1fr) max(215px, calc((100% + 5.35rem) / 5));
  gap: 0.9rem;
  align-items: stretch;
  max-width: 1240px;
  margin: 0 auto;
}
.stack-main { min-width: 0; }

/* Couche : léger cadre de regroupement, étiquette posée sur le bord */
.couche {
  position: relative;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 0.3rem);
  padding: 0.95rem 0.55rem 0.45rem;
  margin-top: 0.55rem;
}
.couche-label {
  position: absolute;
  top: -0.6rem;
  left: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg);
  padding: 0 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  white-space: nowrap;
}
.couche-label::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--card-accent, var(--accent));
}
/* Couche à un seul plan : le cadre et l'étiquette doublonneraient le titre de la carte.
   Le cadre reste (transparent) pour garder l'alignement des cartes et la largeur des cases. */
.couche-solo { border-color: transparent; padding-top: 0.45rem; }

/* Plans empilés dans une même couche (Couche Data) : même écart que les plans côte à côte */
.couche > .plane + .plane { margin-top: 0.55rem; }

.planes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

/* Plan : simple cadre ; ce sont ses fonctionnalités qui mènent au détail */
.plane {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
}
.plane h3 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.plane-mission {
  font-size: 0.79rem;
  color: var(--text-muted);
  margin: 0.1rem 0 0.4rem;
  line-height: 1.4;
}

/* Briques : cases de même taille, réparties en grille (2 par ligne, 4 pour le plan seul de sa couche) */
.brick-tags {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}
/* Plan côte à côte avec moins de briques : ses cases restent centrées en hauteur */
.planes .brick-tags { flex: 1; align-content: center; }
.couche:not(.couche-transverse) > .plane .brick-tags {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  /* Écart élargi : 4 cases de la même largeur que celles des plans côte à côte */
  column-gap: calc((0.55rem + 1.8rem + 0.8rem + 2px) / 3);
}
/* Plan à 5 briques : une seule ligne, cases plus étroites, pour garder le schéma sur une page */
.couche:not(.couche-transverse) > .plane .brick-tags.cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 0.4rem;
}
.brick-tags li { display: flex; }
/* Fonctionnalité : case cliquable vers sa fiche ; seule la bordure réagit au survol */
.brick-tags a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.2rem 0.5rem;
  text-align: center;
  font-size: 0.79rem;
  font-weight: 500;
  line-height: 1.25;
  border-radius: calc(var(--radius) - 0.2rem);
  background: color-mix(in srgb, var(--card-accent) 17%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--card-accent) 38%, transparent);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--t) var(--ease);
}
.brick-tags a:hover { border-color: var(--card-accent); }
.brick-tags a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Flèches entre les couches */
.plane-link {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.72rem;
  margin: 0.15rem 0 0.1rem;
  line-height: 1.2;
}
div.plane-link, .plane-link span { color: var(--accent); font-size: 0.95rem; }

/* Fonctions transverses : colonne qui court le long des trois couches */
.couche-transverse { display: flex; flex-direction: column; }
.couche-transverse .plane { flex: 1; }
/* Pilier : liseré marron foncé ; briques identiques à celles des plans, réparties sur la hauteur */
.couche-transverse .plane { border-left: 3px solid var(--accent-on-dim); }
.couche-transverse .brick-tags { grid-template-columns: minmax(0, 1fr); flex: 1; align-content: space-evenly; }

/* Couleur : même accent pour toutes les couches, fonctions transverses comprises */
.c-data, .c-intel, .c-ux, .c-transverse { --card-accent: var(--accent); --card-dim: var(--accent-dim); }

/* ===== DETAIL VIEW ===== */

/* Fiche lue comme un article : colonne de 720 px au plus, soit des lignes d'environ 90 caractères
   qui remplissent leurs cadres (confort de lecture) ; la vue d'ensemble garde toute la largeur. */
#view-detail { max-width: 720px; }

.detail-hero {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
  margin-bottom: 1.6rem;
  flex-wrap: wrap;
}
.detail-hero-text { flex: 1; min-width: 200px; }
.detail-hero-text h2 {
  font-size: clamp(1.3rem, 2.6vw, 1.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.3rem;
}
/* Titre focalisé par le script à l'ouverture de la fiche (lecteurs d'écran) : pas d'anneau visuel */
.detail-hero-text h2:focus { outline: none; }
.detail-hero-text .meta {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.22rem 0.65rem;
  border-radius: 20px;
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.chip.accent {
  background: var(--card-dim);
  border-color: color-mix(in srgb, var(--card-accent) 30%, transparent);
  color: var(--card-accent);
  font-weight: 600;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: background var(--t) var(--ease);
}
.panel h3 {
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.panel p {
  font-size: 0.9rem;
  line-height: 1.65;
}
.panel p + p { margin-top: 0.7rem; }
.panel .muted { color: var(--text-muted); font-size: 0.87rem; }
.panel .muted strong { color: var(--text); }

.panel ul { list-style: none; }
.panel li {
  font-size: 0.875rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  line-height: 1.55;
}
.panel li:last-child { border-bottom: none; padding-bottom: 0; }
.panel li:first-child { padding-top: 0; }

.li-marker {
  flex-shrink: 0;
  margin-top: 0.12rem;
  font-size: 0.7rem;
  color: var(--accent);
}
.anti-list .li-marker { color: var(--warning); }

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 0.7rem;
}
.kpi {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.85rem 0.95rem;
  transition: border-color var(--t), transform var(--t);
}
.kpi-v {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--accent);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.kpi-k {
  font-size: 0.77rem;
  font-weight: 600;
  margin-top: 0.25rem;
}
.kpi-d {
  font-size: 0.71rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
  line-height: 1.4;
}

/* Tech chips */
.tech-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.tech-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 0.32rem 0.7rem;
  border-radius: 8px;
  font-size: 0.76rem;
  font-family: var(--mono);
  color: var(--text-muted);
  transition: all 0.15s;
  cursor: default;
}
a.tech-chip { text-decoration: none; }
.tech-ext { margin-left: 0.3rem; font-size: 0.7rem; opacity: 0.6; }
.tech-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tech-chip:hover, a.tech-chip:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Fiche du plan : barre d'onglets, un panneau visible à la fois */
.detail-mission { font-size: 0.9rem; color: var(--text-muted); }
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 0.3rem;
  margin-bottom: 1.2rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.48rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background var(--t), color var(--t);
}
.tab:hover { color: var(--text); background: var(--surface2); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tab.active { background: var(--accent-dim); color: var(--accent-on-dim); font-weight: 600; }
.tab .badge {
  font-size: 0.66rem;
  background: var(--surface2);
  padding: 0.02rem 0.4rem;
  border-radius: 20px;
  color: var(--text-dim);
}
.tab.active .badge { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-on-dim); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeUp 0.25s var(--ease); }

/* Pastilles de brique : arrondies, teintées de la couleur de leur couche comme la vue d'ensemble */
.pill-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.brick-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
  text-decoration: none;
  background: color-mix(in srgb, var(--card-accent) 17%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--card-accent) 38%, transparent);
  border-radius: 999px;
  transition: border-color var(--t), background var(--t);
}
.brick-pill:hover, .brick-pill:focus-visible {
  border-color: var(--card-accent);
  background: color-mix(in srgb, var(--card-accent) 26%, var(--surface));
}
.brick-pill:focus-visible { outline: 2px solid var(--card-accent); outline-offset: 2px; }
/* Brique sélectionnée dans le filtre : pleine */
.brick-pill.active {
  background: var(--card-accent);
  border-color: var(--card-accent);
  color: var(--accent-fg);
  font-weight: 600;
}

/* Filtre par brique, entre l'en-tête et les onglets */
/* Toujours sur une ligne (noms courts) ; si l'écran est trop étroit (mobile), la ligne défile
   au doigt. Marge intérieure de 5px : l'anneau de focus n'est pas rogné par le défilement. */
.brick-filter {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: calc(-0.6rem - 5px) -5px calc(1rem - 5px);
  padding: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}
.brick-filter > * { flex-shrink: 0; white-space: nowrap; }
.brick-filter-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-right: 0.2rem;
}

/* Mécanismes : glossaire (nom à gauche, définition à droite, filet entre deux mécanismes ;
   nom au-dessus de la définition sur mobile) */
.mech-list > div {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  column-gap: 1.1rem;
  align-items: baseline;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-soft);
}
.mech-list > div:last-child { border-bottom: 0; }
.mech-list dt { font-size: 0.9rem; font-weight: 600; }
.mech-list dd { font-size: 0.86rem; line-height: 1.55; color: var(--text-muted); }

/* Footer Odinn – styles via classes Tailwind + custom.css */

/* ===== RESPONSIVE ===== */
@media (max-width: 1023px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.1rem;
    padding: 1rem 1rem 3.5rem;
  }
  aside { position: static; }
  .plan-menu { max-height: none; padding: 0; overflow: visible; }
  .plan-menu > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
  }
  .plan-menu > summary::-webkit-details-marker { display: none; }
  .plan-menu > summary::after {
    content: "▾";
    color: var(--text-dim);
    transition: transform var(--t) var(--ease);
  }
  .plan-menu[open] > summary::after { transform: rotate(180deg); }
  #planNav { padding: 0 0.6rem 0.9rem; }
  .stack { grid-template-columns: minmax(0, 1fr); }
  .couche-transverse .brick-tags { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .planes { grid-template-columns: minmax(0, 1fr); }
  .stack .couche > .plane .brick-tags,
  .stack .couche > .plane .brick-tags.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 0.4rem; }
  .couche-label { white-space: normal; }
  .detail-hero { gap: 0.85rem; }
  /* Tous les onglets visibles, sur deux lignes si besoin, plutôt qu'un défilement caché */
  .tabs { flex-wrap: wrap; }
  .mech-list > div { grid-template-columns: minmax(0, 1fr); }
  .mech-list dd { margin-top: 0.15rem; }
  .panel { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
