/*
 * Takt — holoscope of the Holon circle "Chaînes de valeur" (value-chain analysis).
 *
 * This software is free software: its user may do whatever they want with it.
 * It was developed by Franck LEFEVRE for K1 (https://k1info.com), helped by his team of
 * free, kind and funny autonomous beings.
 * Reader: please use the enormous power of this software to do things that are good for
 * things and people, always making sure that it harms nothing and no one.
 *
 * Styles of the holoscope shell: colour tokens (light/dark), tab bar, two-column layout
 * (content + explanation aside), single column under 800px.
 *
 * HISTORY
 *   2026-11-04 16:50 v0.1.0 — file created: tokens, tabs, layout, dark mode.
 *   2026-11-04 17:40 v0.1.2 — chain screen: category colours, tiles, lead bar, swimlanes, help bubbles, step detail.
 */

:root {
  --bg: #fafaf7;
  --fg: #1d1d1b;
  --muted: #66665f;
  --accent: #2f6f5e;
  --panel: #ffffff;
  --border: #deded6;
  --va: #2f8f5b;
  --nva-needed: #c99a2e;
  --nva: #c4493c;
  --wait: #b9b9b0;
  --lane: #f1f1ec;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --fg: #ecece6;
    --muted: #a3a39a;
    --accent: #6fbfa8;
    --panel: #20201d;
    --border: #3a3a35;
    --va: #4fb37e;
    --nva-needed: #d9ae4a;
    --nva: #e0695c;
    --wait: #5a5a53;
    --lane: #1a1a18;
  }
}

* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--fg); }
header { padding: 16px 24px 0; border-bottom: 1px solid var(--border); }
h1 { margin: 0 0 12px; font-size: 1.4rem; }
h1 .sub { font-weight: 400; color: var(--muted); font-size: 1rem; }
nav { display: flex; gap: 4px; }
nav button {
  border: 1px solid var(--border); border-bottom: none; background: transparent; color: var(--fg);
  padding: 8px 16px; border-radius: 6px 6px 0 0; cursor: pointer; font: inherit;
}
nav button[aria-selected="true"] { background: var(--panel); color: var(--accent); font-weight: 600; }
.layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; padding: 24px; }
main, aside { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; }
aside h3 { margin: 12px 0 4px; font-size: 0.95rem; color: var(--accent); }
aside h3:first-child { margin-top: 0; }
a { color: var(--accent); }
.pending { color: var(--muted); font-style: italic; }

/* Chain screen */
.banner { margin: 0 0 8px; padding: 6px 10px; border-left: 4px solid var(--nva-needed); background: var(--lane); font-size: 0.9rem; }
.source { color: var(--muted); font-size: 0.85rem; margin-top: 0; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
main h3 { margin: 20px 0 8px; font-size: 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.tile-label { font-size: 0.8rem; color: var(--muted); }
.tile-value { font-size: 1.25rem; font-weight: 600; }
.leadbar { display: flex; height: 22px; border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.seg { height: 100%; min-width: 2px; }
.cat-VA { --c: var(--va); } .cat-NVA_NEEDED { --c: var(--nva-needed); } .cat-NVA { --c: var(--nva); } .cat-WAIT { --c: var(--wait); }
.seg, .swatch { background: var(--c); }
.legend { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.85rem; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.lanes-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
.lanes { display: grid; gap: 4px; padding: 4px; min-width: max-content; }
.lane-head { position: sticky; left: 0; z-index: 1; background: var(--panel); font-size: 0.85rem; font-weight: 600; padding: 6px; border-right: 1px solid var(--border); }
.lane-cell { background: var(--lane); border-radius: 4px; min-height: 64px; }
.step {
  text-align: left; font: inherit; font-size: 0.8rem; color: var(--fg); cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-left: 5px solid var(--c);
  border-radius: 4px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.step:hover, .step:focus-visible { outline: 2px solid var(--accent); }
.step-num { font-weight: 700; color: var(--c); }
.step-badges { display: flex; flex-wrap: wrap; gap: 3px; }
.badge { font-size: 0.7rem; padding: 0 5px; border-radius: 8px; border: 1px solid var(--border); color: var(--muted); }
.badge.ext { border-color: var(--nva); color: var(--nva); }
.loops { padding-left: 18px; font-size: 0.9rem; }
.help {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted);
  font-size: 0.65rem; cursor: help; vertical-align: middle;
}
.help:hover::after, .help:focus::after {
  content: attr(data-tip); position: absolute; z-index: 10; bottom: 130%; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 260px; padding: 6px 8px; border-radius: 4px;
  background: var(--fg); color: var(--bg); font-size: 0.8rem; line-height: 1.35; white-space: normal;
}
aside dl { margin: 0; }
aside dt { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }
aside dd { margin: 0; }
aside ul { padding-left: 18px; margin: 4px 0; }
.back { font: inherit; font-size: 0.85rem; background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; margin-bottom: 8px; }

@media (max-width: 800px) {
  header, .layout { padding-left: 16px; padding-right: 16px; }
  .layout { grid-template-columns: 1fr; }
}
