/*
  Styles du portfolio.
  Mise en page : écran unique, constellation plein cadre, journal en panneau à droite
  (feuille repliable en bas sur mobile). Thème sombre unique, assumé.
  Les couleurs des branches viennent de data.js (variable --c posée sur chaque élément).
*/
:root {
  color-scheme: dark;
  --void: #100d0a; --void-2: #191410; --glow-bg: #241b13;
  --stone: #1e1812; --stone-2: #2a2119; --socket: #17120e; --socket-deep: #0b0907;
  --line: #3a3026; --line-strong: #5a4b3b;
  --gold: #c9a35b; --gold-bright: #f2d58e; --gold-dim: #7d6640;
  --text: #ebdfc6; --muted: #a39682; --faint: #71665a;
  --ok: #93c487; --warn: #e2b75c;
  --shadow: rgba(0, 0, 0, .5);
  --f-display: "Marcellus SC", "Trajan Pro", Georgia, serif;
  --f-body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--void); color: var(--text); font-family: var(--f-body); font-size: 15px; line-height: 1.4; overflow: hidden; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.fatal { position: fixed; inset: 16px 16px auto; z-index: 20; margin: 0; padding: 14px 16px; background: var(--stone); border: 1px solid var(--warn); border-radius: 4px; color: var(--text); font-family: var(--f-body); }

.app { display: flex; flex-direction: column; height: 100%; }
.app > .bar { flex: none; }
.app > .stage { flex: 1 1 auto; }

/* En-tête */
.bar { display: flex; align-items: center; gap: 14px 24px; flex-wrap: wrap; padding-top: calc(10px + env(safe-area-inset-top, 0px)); padding-bottom: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); background: linear-gradient(var(--stone), var(--void-2)); border-bottom: 1px solid var(--line); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sigil { width: 34px; height: 34px; flex: none; }
.sg-ring { fill: none; stroke: var(--gold); stroke-width: 1.5; }
.sg-core { fill: var(--gold); }
.sg-dots circle { fill: var(--gold-bright); }
.brand-text { min-width: 0; }
.brand h1 { font-family: var(--f-display); font-weight: 400; font-size: 22px; letter-spacing: .1em; margin: 0; color: var(--gold-bright); line-height: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.chip { font-family: var(--f-body); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); border-radius: 999px; padding: 2px 8px; white-space: nowrap; line-height: 1.4; }
.stats { display: flex; gap: 22px; margin-left: auto; }
.stat .k { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); }
.stat .v { font-family: var(--f-display); font-size: 21px; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .v small { font-size: 13px; color: var(--muted); }
.tools { display: flex; gap: 8px; align-items: center; }
.search { position: relative; display: block; }
.search .mag { position: absolute; left: 10px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; fill: none; stroke: var(--muted); stroke-width: 2; pointer-events: none; }
.search input { width: 250px; padding: 8px 34px 8px 32px; background: var(--socket); border: 1px solid var(--line-strong); border-radius: 4px; color: var(--text); font: inherit; font-size: 14px; }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.q-count { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-family: var(--f-mono); font-size: 11px; color: var(--muted); pointer-events: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 12px; background: var(--stone-2); border: 1px solid var(--line-strong); border-radius: 4px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--gold-dim); color: var(--gold-bright); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 16px; }

/* Scène */
.stage { position: relative; overflow: hidden; min-height: 0; background: radial-gradient(ellipse at 42% 46%, var(--glow-bg) 0%, var(--void) 62%); }
#tree { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
#tree.dragging { cursor: grabbing; }

/* Constellation */
.star { fill: var(--text); }
.guide { fill: none; stroke: var(--line); stroke-width: 1.5; }
.guide.faint { stroke-dasharray: 2 10; opacity: .6; }
.socket { fill: var(--c); opacity: .85; }
.branch-label { font-family: var(--f-display); font-size: calc(36px * var(--bs, 1)); letter-spacing: .12em; text-anchor: middle; dominant-baseline: central; fill: var(--c); opacity: .55; pointer-events: none; }
.edge { stroke: var(--line); stroke-width: 3; stroke-linecap: round; transition: opacity .25s; }
.edge.extra { stroke-width: 2; }
.edge.apprentissage { stroke: var(--gold-dim); stroke-dasharray: 7 7; }
.edge.maitrise { stroke: var(--gold); stroke-width: 4; }
.edge.maitrise.extra { stroke-width: 2.5; }
.glow { stroke: var(--gold); stroke-width: 12; stroke-linecap: round; opacity: .14; transition: opacity .25s; }

.node { cursor: pointer; transition: opacity .25s; }
.node:focus { outline: none; }
.node .hit { fill: transparent; }
.node .frame { fill: var(--socket); stroke: var(--line-strong); stroke-width: 2.5; }
.node .frame2 { fill: none; stroke: var(--line-strong); stroke-width: 1.5; }
.node .ticks { fill: none; stroke: var(--line-strong); stroke-width: 3; stroke-dasharray: 2 7; }
.node .halo { fill: none; stroke: var(--line); stroke-width: 1.5; }
.node .core { fill: var(--socket-deep); }
.node .abbr { font-family: var(--f-mono); font-size: 10px; font-weight: 500; fill: var(--faint); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.node.cle .abbr { font-size: 12px; }
.node.maitrise .frame { stroke: var(--gold); }
.node.maitrise .frame2, .node.maitrise .ticks, .node.maitrise .halo { stroke: var(--gold-dim); }
.node.maitrise .core { fill: var(--c); filter: url(#glow); animation: ignite .9s ease-out both; animation-delay: calc(var(--ring, 0) * 140ms + 120ms); }
.node.maitrise .abbr { fill: var(--socket-deep); }
.node.apprentissage .frame { stroke: var(--c); stroke-dasharray: 5 4; }
.node.apprentissage .core { fill: color-mix(in srgb, var(--c) 26%, var(--socket)); }
.node.apprentissage .abbr { fill: var(--text); }
.node.verrouille { opacity: .55; }
.node:hover .frame, .node:focus-visible .frame { stroke: var(--gold-bright); stroke-width: 3.5; }
.lbl { font-family: var(--f-body); font-size: 13px; fill: var(--text); text-anchor: middle; dominant-baseline: central; pointer-events: none; paint-order: stroke; stroke: var(--void); stroke-width: 4px; stroke-linejoin: round; }
.lbl.major { font-family: var(--f-display); font-size: calc(15px * var(--ls, 1)); letter-spacing: .04em; fill: var(--gold-bright); }
.node.verrouille .lbl { fill: var(--muted); }
.node.apprentissage .lbl.major { fill: var(--text); }
#tree.far .lbl.minor { display: none; }
#tree.veryfar .lbl { display: none; }

.origine .ticks { stroke: var(--gold-dim); }
.origine .frame { stroke: var(--gold); stroke-width: 3; }
.origine .frame2 { stroke: var(--gold-dim); }
.ocore { fill: url(#ograd); }
.og-a { stop-color: var(--stone-2); }
.og-b { stop-color: var(--socket-deep); }
.otitle { font-family: var(--f-display); font-size: 18px; letter-spacing: .12em; fill: var(--gold-bright); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.osub { font-family: var(--f-body); font-size: 9.5px; letter-spacing: .24em; text-transform: uppercase; fill: var(--muted); text-anchor: middle; dominant-baseline: central; pointer-events: none; }

.sel { fill: none; stroke: var(--gold-bright); stroke-width: 2; stroke-dasharray: 3 7; animation: orbit 4s linear infinite; pointer-events: none; }

#tree.focus .node:not(.hl) { opacity: .16; }
#tree.focus .edge:not(.hl) { opacity: .1; }
#tree.focus .glow { opacity: .03; }
#tree.focus .node.hl .frame { stroke: var(--gold-bright); }
#tree.focus .edge.hl { stroke: var(--gold-bright); stroke-width: 5; stroke-dasharray: 12 9; animation: flow 1.1s linear infinite; }

@keyframes ignite { from { opacity: .3; } to { opacity: 1; } }
@keyframes flow { to { stroke-dashoffset: -42; } }
@keyframes orbit { to { stroke-dashoffset: -60; } }

/* Surcouches de la scène */
.legend { position: absolute; top: 14px; left: max(14px, env(safe-area-inset-left, 0px)); z-index: 3; max-width: 230px; background: color-mix(in srgb, var(--stone) 90%, transparent); border: 1px solid var(--line); border-radius: 4px; font-size: 13.5px; }
.legend summary { cursor: pointer; padding: 8px 12px; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); list-style-position: inside; }
.lg { padding: 2px 12px 12px; display: grid; gap: 12px; }
.lg ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lg li { display: flex; align-items: center; gap: 9px; }
.lg .dot { width: 10px; height: 10px; }
.lg svg { width: 22px; height: 22px; flex: none; overflow: visible; }
.lg .node { cursor: default; }
.lg .node.maitrise .core { animation: none; }
.zoom { position: absolute; left: max(14px, env(safe-area-inset-left, 0px)); bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 3; }
.zbtn { width: 38px; height: 38px; display: grid; place-items: center; background: var(--stone); border: 1px solid var(--line-strong); border-radius: 4px; font-size: 19px; line-height: 1; cursor: pointer; }
.zbtn:hover { border-color: var(--gold-dim); color: var(--gold-bright); }
.zbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.hint { position: absolute; left: calc((100% - 388px) / 2); bottom: 18px; transform: translateX(-50%); margin: 0; padding: 6px 14px; background: color-mix(in srgb, var(--stone) 85%, transparent); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13px; white-space: nowrap; z-index: 2; pointer-events: none; }
.h-mob { display: none; }
.tip { position: absolute; transform: translate(-50%, -100%); background: var(--stone); border: 1px solid var(--gold-dim); padding: 6px 10px; border-radius: 4px; pointer-events: none; white-space: nowrap; z-index: 6; box-shadow: 0 6px 18px var(--shadow); }
.tip b { display: block; font-family: var(--f-display); font-weight: 400; color: var(--gold-bright); font-size: 14px; }
.tip span { color: var(--muted); font-size: 12px; }

/* Panneau */
.panel { position: absolute; top: 14px; right: max(14px, env(safe-area-inset-right, 0px)); bottom: 14px; width: 360px; max-width: calc(100% - 28px); display: flex; flex-direction: column; background: color-mix(in srgb, var(--stone) 94%, transparent); border: 1px solid var(--line-strong); border-top: 2px solid var(--gold-dim); border-radius: 5px; box-shadow: 0 18px 40px var(--shadow); z-index: 4; }
.sheet-toggle { display: none; }
.panel-body { overflow: auto; padding: 18px 18px 22px; flex: 1; min-height: 0; overscroll-behavior: contain; }
.eyebrow { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.p-title { font-family: var(--f-display); font-weight: 400; font-size: 26px; line-height: 1.15; margin: 0 0 10px; color: var(--gold-bright); text-wrap: balance; }
.lede, .desc { margin: 0 0 14px; line-height: 1.5; max-width: 65ch; }
.qmeta { margin: -4px 0 12px; color: var(--muted); font-size: 14px; }
.flavor { font-style: italic; color: var(--gold); border-left: 2px solid var(--gold-dim); padding-left: 12px; margin: 0 0 14px; }
.note { color: var(--muted); font-size: 13.5px; margin: 12px 0 0; line-height: 1.45; }
.muted { color: var(--muted); margin: 0; }
.sub { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 20px 0 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.meta-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; }
.status { display: inline-block; font-size: 12px; letter-spacing: 0; text-transform: none; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--faint); white-space: nowrap; }
.status.maitrise, .status.terminee { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.status.apprentissage, .status.en-cours { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.rank { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.rank b { width: 8px; height: 8px; transform: rotate(45deg); border: 1px solid var(--gold); display: inline-block; }
.rank b.f { background: var(--gold); }
.rank span { margin-left: 4px; }
.back { background: none; border: none; color: var(--muted); font-size: 13.5px; padding: 0; margin: 0 0 14px; cursor: pointer; }
.back:hover { color: var(--gold-bright); }
.qlist, .qlinks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qrow, .qlink { width: 100%; text-align: left; display: grid; gap: 4px; padding: 11px 12px; background: var(--socket); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.qrow:hover, .qlink:hover { border-color: var(--gold-dim); background: var(--stone-2); }
.qrow-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.qrow-title { font-weight: 700; min-width: 0; }
.qrow-meta { color: var(--muted); font-size: 13px; }
.qrow-dots { display: flex; gap: 5px; margin-top: 2px; }
.qrow-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.deliv { margin: 0; padding-left: 18px; display: grid; gap: 4px; line-height: 1.45; }
.deliv li::marker { color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-skill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border: 1px solid var(--line-strong); background: var(--socket); border-radius: 999px; font-size: 13.5px; cursor: pointer; }
.chip-skill:hover { border-color: var(--gold-dim); color: var(--gold-bright); }
.chip-skill i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.chip-skill.apprentissage i { background: transparent; border: 1.5px dashed var(--c); }
.chip-skill.verrouille { color: var(--muted); }
.cs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.cs div { background: var(--socket); border: 1px solid var(--line); padding: 10px 12px; border-radius: 4px; display: grid; gap: 2px; }
.cs .v { font-family: var(--f-display); font-size: 24px; color: var(--gold-bright); font-variant-numeric: tabular-nums; line-height: 1.1; }
.cs .v small { font-size: 14px; color: var(--muted); }
.cs .k { font-size: 12.5px; color: var(--muted); }
.bars { display: grid; gap: 9px; }
.barrow { display: grid; grid-template-columns: 112px 1fr 38px; align-items: center; gap: 10px; font-size: 13.5px; }
.meter { height: 6px; background: var(--socket-deep); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--c); }
.num { font-family: var(--f-mono); font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* Vue classique */
.classic { position: absolute; inset: 0; overflow: auto; background: var(--void); z-index: 8; padding-top: 24px; padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.classic-inner { max-width: 1080px; margin: 0 auto; display: grid; gap: 12px; }
.classic-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.classic-head > div { min-width: 0; }
.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.bcard, .mcard { background: var(--stone); border: 1px solid var(--line); border-radius: 5px; padding: 14px 16px; min-width: 0; }
.bcard { border-top: 2px solid var(--c); }
.bcard h4, .mcard h4 { margin: 0 0 10px; font-family: var(--f-display); font-weight: 400; font-size: 18px; color: var(--gold-bright); display: flex; align-items: center; gap: 8px; }
.bcard h4 .num { margin-left: auto; }
.bcard ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bcard li { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bcard li button { background: none; border: none; padding: 0; text-align: left; cursor: pointer; min-width: 0; }
.bcard li button:hover { color: var(--gold-bright); }
.bcard li.verrouille button { color: var(--muted); }
.mission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.mtop { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mtop h4 { margin-bottom: 4px; }
.mcard p { margin: 6px 0 10px; line-height: 1.45; }

@media (max-width: 1100px) { .stats { display: none; } .tools { margin-left: auto; } }
@media (max-width: 720px) {
  .bar { gap: 10px; padding-bottom: 12px; }
  .brand h1 { font-size: 20px; }
  .tools { width: 100%; margin-left: 0; }
  .search { flex: 1; min-width: 0; }
  .search input { width: 100%; }
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; max-height: 58%; border-radius: 12px 12px 0 0; border-left: none; border-right: none; border-bottom: none; }
  .panel.collapsed .panel-body { display: none; }
  .sheet-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 16px 18px calc(12px + env(safe-area-inset-bottom, 0px)); background: none; border: none; font-family: var(--f-display); font-size: 17px; color: var(--gold-bright); cursor: pointer; position: relative; text-align: left; }
  .panel:not(.collapsed) .sheet-toggle { padding-bottom: 12px; }
  .sheet-toggle .grip { position: absolute; top: 6px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: var(--line-strong); }
  .sheet-toggle .lbl-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sheet-toggle .chev { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; transition: transform .2s; }
  .panel:not(.collapsed) .sheet-toggle .chev { transform: rotate(180deg); }
  .panel-body { padding-top: 4px; padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)); }
  .legend { top: 10px; left: max(10px, env(safe-area-inset-left, 0px)); }
  .zoom { left: auto; right: max(10px, env(safe-area-inset-right, 0px)); top: 10px; bottom: auto; }
  .hint { left: 50%; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
  .h-desk { display: none; } .h-mob { display: inline; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
