/* Carte Ragnamod VI. Mise en page : en-tête avec l'équipe, prochaines étapes calculées, carte en 5 colonnes
   (phases) reliées par des flèches, panneau de détail à droite ; sur téléphone, liste empilée et détail sous le mod. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("polices/inter.woff2") format("woff2"); }
@font-face { font-family: "Pixelify Sans"; font-style: normal; font-weight: 500 600; font-display: swap; src: url("polices/pixelify-sans.woff2") format("woff2"); }

:root {
  --bg: #ECEFEA;
  --surface: #F9FAF7;
  --sunk: #E3E7E1;
  --ink: #1C221E;
  --muted: #59655D;
  --line: #C3CAC2;
  --edge: #9AA49B;
  --copper: #B05A22;
  --amethyst: #7650BA;
  --prismarine: #1F7F7A;
  --gold: #9C780A;
  --redstone: #BF3226;
  --redstone-soft: rgba(191, 50, 38, 0.15);
  --ok: #2C7748;
  --f-display: "Pixelify Sans", "Courier New", monospace;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131816; --surface: #1C231F; --sunk: #171D1A; --ink: #E3E9E2; --muted: #97A39B;
    --line: #35403A; --edge: #55625A; --copper: #E58C52; --amethyst: #AF93EE; --prismarine: #4CC3BA;
    --gold: #E1BB45; --redstone: #FF6D5E; --redstone-soft: rgba(255, 109, 94, 0.17); --ok: #5DC88D;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 28px 48px;
}
[hidden] { display: none !important; }
.wrap { max-width: 1440px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
p { margin: 0; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.dom-techno { --dom: var(--copper); }
.dom-magie { --dom: var(--amethyst); }
.dom-monde { --dom: var(--prismarine); }
.dom-fin { --dom: var(--gold); }
.sw { width: 9px; height: 9px; background: var(--dom); flex: none; display: inline-block; }

/* En-tête */
header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 24px 40px; align-items: end; }
.eyebrow { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
h1 { font-family: var(--f-display); font-weight: 600; font-size: clamp(32px, 5vw, 52px); line-height: 1; letter-spacing: 0.01em; }
.lead { margin-top: 12px; max-width: 62ch; color: var(--muted); font-size: 16px; }
.team { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.team-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.team-name { font-weight: 600; }
.team select { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; max-width: 60%; }
.team-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.team-line b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { height: 10px; background: var(--sunk); border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; width: 0; background: var(--ok); }
.team-who, .fresh { font-size: 13px; color: var(--muted); }
.fresh { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--edge); flex: none; }
.fresh.live .dot { background: var(--ok); }
.fresh.stale .dot { background: var(--redstone); }
@media (prefers-reduced-motion: no-preference) {
  .fresh.live .dot { animation: pouls 2.4s ease-in-out infinite; }
  @keyframes pouls { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
}

/* Prochaines étapes */
.steps h2, .legend h2, .side-mods h2 { font-size: 13px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.steps ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step {
  width: 100%; height: 100%; text-align: left; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px; padding: 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 8px; align-content: start;
}
.step:hover { border-color: var(--redstone); }
.step-n {
  grid-row: span 3; width: 30px; height: 30px; display: grid; place-items: center; font-family: var(--f-display);
  font-size: 17px; color: var(--redstone); border: 1.5px solid var(--redstone); background: var(--redstone-soft);
}
.step-t { font-weight: 600; line-height: 1.3; }
.step-d { font-size: 13px; color: var(--muted); }
.step-o { font-size: 13px; }
.step-o b { font-weight: 600; }
.steps-done { font-size: 14px; color: var(--muted); }

/* Légende */
.legend-row { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; font-size: 13px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 8px; }
.lg-box { width: 30px; height: 18px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 4px; flex: none; }
.lg-box.fait { border-color: var(--ok); }
.lg-box.now { border: 2px solid var(--redstone); box-shadow: 0 0 0 3px var(--redstone-soft); }
.lg-box.lock { border-style: dashed; background: var(--bg); }
.lg-ok { stroke: var(--ok); stroke-width: 2; }
.lg-wait { stroke: var(--edge); stroke-width: 2; stroke-dasharray: 4 4; }
.lg-hint { color: var(--ink); }

/* Carte */
.board { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.map-scroll {
  overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px 22px;
  background-color: var(--sunk);
  background-image: radial-gradient(var(--line) 1px, transparent 1.2px);
  background-size: 18px 18px;
}
.map { position: relative; display: grid; grid-template-columns: repeat(5, minmax(152px, 1fr)); column-gap: 46px; min-width: 940px; }
.map svg.edges { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; overflow: visible; }
.col { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.col-h { display: flex; align-items: center; gap: 9px; font-family: var(--f-display); font-weight: 600; font-size: 16px; line-height: 1.1; }
.col-n { width: 24px; height: 24px; display: grid; place-items: center; flex: none; font-size: 14px; background: var(--surface); border: 1.5px solid var(--line); }
.col-s { font-size: 12px; color: var(--muted); min-height: 2.6em; }
.nodes { display: flex; flex-direction: column; gap: 10px; }

.node {
  width: 100%; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 5px;
  padding: 9px 11px 10px; border-radius: 6px; border: 1.5px solid var(--line); background: var(--surface);
}
.node .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.node .nm { font-weight: 600; font-size: 14px; line-height: 1.25; }
.node .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.node .count { margin-left: auto; font-variant-numeric: tabular-nums; }
.node .via { display: none; font-size: 12px; color: var(--muted); }
.node .ico { flex: none; margin-top: 1px; }
.node .badge {
  flex: none; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--redstone); border: 1px solid var(--redstone); padding: 1px 5px; border-radius: 3px; line-height: 1.4;
}
.node.st-fait { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.node.st-fait .ico { color: var(--ok); }
.node.st-now { border: 2px solid var(--redstone); box-shadow: 0 0 0 4px var(--redstone-soft); padding: 8.5px 10.5px 9.5px; }
.node.st-lock { border-style: dashed; background: var(--bg); }
.node.st-lock .nm, .node.st-lock .ico { color: var(--muted); }
.node:hover { border-color: var(--ink); }
.node.sel { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.map.focus .node:not(.sel):not(.rel) { opacity: 0.4; }

.edge { fill: none; stroke: var(--edge); stroke-width: 1.4; stroke-dasharray: 4 4; marker-end: url(#m-base); }
.edge.done { stroke: var(--ok); stroke-dasharray: none; opacity: 0.75; marker-end: url(#m-done); }
.map.focus .edge { opacity: 0.1; }
.map.focus .edge.on { opacity: 1; stroke: var(--ink); stroke-width: 2.2; marker-end: url(#m-on); }
.map.focus .edge.on.done { stroke: var(--ok); marker-end: url(#m-done); }
.mk-base { fill: var(--edge); }
.mk-done { fill: var(--ok); }
.mk-on { fill: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .node, .edge { transition: opacity 0.18s ease, border-color 0.15s ease; }
}

/* Panneau de détail */
.side { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.p-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.pill { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 3px; border: 1px solid var(--line); color: var(--muted); }
.pill.st-fait { color: var(--ok); border-color: var(--ok); }
.pill.st-now { color: var(--redstone); border-color: var(--redstone); background: var(--redstone-soft); }
.pill.st-ouvert { color: var(--ink); border-color: var(--ink); }
.pill.st-lock { border-style: dashed; }
.p-name { font-size: 22px; font-weight: 600; line-height: 1.15; }
.p-what { color: var(--muted); }
.p-note { font-size: 13px; padding: 8px 10px; border-left: 3px solid var(--redstone); background: var(--redstone-soft); }
.p-q { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.p-sec { display: flex; flex-direction: column; gap: 7px; }
.p-sec h4 { font-size: 12px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.p-sec ul, .p-sec ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.req li, .gives li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 6px; font-size: 14px; line-height: 1.35; }
.req .mk { font-weight: 600; color: var(--muted); text-align: center; }
.req li.ok .mk { color: var(--ok); }
.gives .mk { color: var(--muted); text-align: center; }
.src { display: block; font-size: 12px; color: var(--muted); }
.lnk { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; font-weight: 500; }
.lnk:hover { text-decoration-color: var(--ink); }
.how { counter-reset: how; }
.how li { counter-increment: how; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 6px; font-size: 14px; line-height: 1.4; }
.how li::before { content: counter(how); font-family: var(--f-display); color: var(--muted); }
.none { font-size: 14px; color: var(--muted); }
.close { align-self: flex-start; background: none; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.close:hover { border-color: var(--ink); }
.empty { color: var(--muted); font-size: 14px; }

/* Hors chemin */
.side-mods h2 { margin-bottom: 4px; }
.side-mods p.sub { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.chip .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip .why { color: var(--muted); }

.notice { font-size: 14px; padding: 10px 12px; border: 1px solid var(--redstone); background: var(--redstone-soft); border-radius: 8px; }
footer { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }

@media (max-width: 1099px) {
  .board { grid-template-columns: minmax(0, 1fr) 290px; }
  .steps ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 819px) {
  header { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
  .side { display: none; }
  .map-scroll { overflow: visible; border: 0; padding: 0; background: none; }
  .map { display: flex; flex-direction: column; gap: 26px; min-width: 0; }
  .map svg.edges { display: none; }
  .col-s { min-height: 0; }
  .node .via { display: block; }
  .map.focus .node:not(.sel):not(.rel) { opacity: 1; }
}
@media (max-width: 520px) {
  .steps ol { grid-template-columns: 1fr; }
}
