/* ==========================================================
   Suivi de projet ISM Thiès — feuille de style
   ========================================================== */
:root {
  color-scheme: dark;
  --bg: #060c18;
  --bg-2: #0a1426;
  --surface: rgba(17, 29, 52, 0.72);
  --surface-solid: #111d34;
  --surface-2: #16243f;
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #e8eef9;
  --text-2: #a7b4cc;
  --text-3: #73819b;
  --teal: #2dd4bf;
  --sky: #38bdf8;
  --amber: #f5b942;
  --green: #22c55e;
  --slate: #64748b;
  --red: #ef4444;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 50px -24px rgba(0, 0, 0, 0.7);
  --font-display: "Sora", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }

.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(45, 212, 191, 0.14), transparent 60%),
    radial-gradient(700px 500px at -10% 30%, rgba(56, 189, 248, 0.10), transparent 60%),
    radial-gradient(600px 400px at 50% 110%, rgba(167, 139, 250, 0.08), transparent 60%),
    linear-gradient(var(--bg), var(--bg-2));
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gutter);
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(6, 12, 24, 0.78);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 12px;
  font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: 0.04em;
  color: #04201c;
  background: linear-gradient(135deg, var(--teal), var(--sky));
  box-shadow: 0 6px 20px -6px rgba(45, 212, 191, 0.6);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-family: var(--font-display); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--text-3); font-size: 12px; }

.live {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line);
}
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--slate); }
.live.ok .dot { background: var(--green); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); animation: ping 2s infinite; }
.live.err .dot { background: var(--red); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55);} 80%,100% { box-shadow: 0 0 0 8px rgba(34,197,94,0);} }

main { padding: 0 var(--gutter) 40px; max-width: 1240px; margin: 0 auto; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(16px, 4vw, 48px);
  align-items: center; padding: clamp(24px, 5vw, 56px) 0 clamp(8px, 2vw, 24px);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--teal);
}
.eyebrow::before { content: ""; width: 22px; height: 2px; background: currentColor; border-radius: 2px; }
.hero h1 { font-size: clamp(26px, 4.4vw, 46px); line-height: 1.1; font-weight: 700; }
.lead { color: var(--text-2); font-size: clamp(15px, 1.6vw, 17px); margin: 16px 0 24px; max-width: 56ch; }
.hero-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.hero-meta div { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.hero-meta dt { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
.hero-meta dd { margin: 4px 0 0; font-weight: 700; font-size: 14px; }

.hero-3d { position: relative; aspect-ratio: 1 / 1; width: 100%; max-width: 520px; justify-self: center; }
#ringCanvas, #barsCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ring-fallback {
  display: none; position: absolute; inset: 14%; border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--p, 0) * 1%), rgba(30, 42, 68, 0.9) 0);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%);
          mask: radial-gradient(circle, transparent 62%, #000 63%);
}
.no-webgl .ring-fallback { display: block; }
.ring-label {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; text-align: center;
}
.ring-value { display: flex; align-items: baseline; font-family: var(--font-display); text-shadow: 0 4px 24px rgba(6, 12, 24, 0.9); }
.ring-value strong { font-size: clamp(48px, 9vw, 76px); font-weight: 700; line-height: 1; }
.ring-value span { font-size: clamp(20px, 3vw, 28px); color: var(--teal); margin-left: 2px; font-weight: 600; }
.ring-label small { color: var(--text-2); font-size: 13px; margin-top: 6px; text-shadow: 0 2px 12px rgba(6,12,24,.9); }
.ring-legend {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 16px;
  margin: 0; padding: 0; list-style: none; font-size: 12px; color: var(--text-2);
}
.ring-legend li { display: inline-flex; align-items: center; gap: 6px; }
.ring-legend i, .status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.s-termine { background: var(--green); }
.s-en_cours { background: var(--amber); }
.s-a_venir { background: var(--slate); }
.s-bloque { background: var(--red); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 8px 0 8px; perspective: 900px; }
.kpi {
  position: relative; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), rgba(45, 212, 191, 0.14), transparent 60%);
}
.kpi:hover::after { opacity: 1; }
.kpi-label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.kpi-value { font-family: var(--font-display); font-size: clamp(26px, 3.4vw, 36px); line-height: 1.1; color: var(--green); }
.kpi-value.accent-amber { color: var(--amber); }
.kpi-value.accent-teal { color: var(--teal); }
.kpi-value.muted { color: var(--text-2); }
.kpi-sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }

.tilt { transform-style: preserve-3d; transition: transform .25s ease, border-color .25s; will-change: transform; }
.tilt:hover { border-color: var(--line-strong); }

/* ---------- Blocks ---------- */
.block {
  margin-top: 22px; padding: clamp(16px, 3vw, 28px); border-radius: calc(var(--radius) + 4px);
  background: rgba(10, 20, 38, 0.6); border: 1px solid var(--line);
}
.block-head { margin-bottom: 18px; }
.block-head.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.block-head h2 { font-size: clamp(19px, 2.4vw, 24px); }
.block-head p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.hint { color: var(--text-3) !important; }

/* ---------- Flow ---------- */
.flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; perspective: 900px; counter-reset: f; }
.flow-step {
  position: relative; padding: 16px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.flow-step b { font-family: var(--font-display); font-size: 14px; font-weight: 600; }
.flow-step span:last-child { font-size: 13px; color: var(--text-2); }
.flow-num {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 6px;
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  background: rgba(56, 189, 248, 0.14); color: var(--sky); border: 1px solid rgba(56, 189, 248, 0.3);
}
.flow-last .flow-num { background: rgba(34, 197, 94, 0.16); color: var(--green); border-color: rgba(34, 197, 94, 0.35); }
.flow-step:not(:last-child)::after {
  content: "→"; position: absolute; right: -11px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; display: grid; place-items: center; z-index: 2;
  font-size: 12px; color: var(--teal); background: var(--bg-2); border: 1px solid var(--line-strong); border-radius: 50%;
}

/* ---------- Phases 3D ---------- */
.phases-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: center; }
.bars-wrap { position: relative; aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden; background: radial-gradient(ellipse at 50% 80%, rgba(56,189,248,.08), transparent 70%); touch-action: pan-y; cursor: grab; }
.bars-wrap:active { cursor: grabbing; }
.no-webgl .bars-wrap { display: none; }
.no-webgl .phases-grid { grid-template-columns: 1fr; }
.bar-labels { position: absolute; inset: 0; pointer-events: none; }
.bar-label {
  position: absolute; transform: translate(-50%, -130%); white-space: nowrap;
  padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 700;
  background: rgba(6, 12, 24, 0.82); border: 1px solid var(--line-strong);
}
.phase-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.phase-legend li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; }
.phase-legend .swatch { width: 12px; height: 12px; border-radius: 4px; }
.phase-legend .name { font-weight: 600; font-size: 14px; min-width: 0; }
.phase-legend .pct { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.phase-legend .track { grid-column: 1 / -1; }

.track { height: 6px; border-radius: 6px; background: rgba(148, 163, 184, 0.14); overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: inherit; width: 0; transition: width 1s cubic-bezier(.2,.8,.2,1); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: transparent; border: 1px solid var(--line-strong); color: var(--text-2);
  transition: all .2s;
}
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--teal); border-color: var(--teal); color: #04201c; }

/* ---------- Phase list ---------- */
.phase-list { display: flex; flex-direction: column; gap: 12px; }
.phase {
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  overflow: hidden;
}
.phase-head {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px;
  padding: 16px 18px; background: none; border: 0; text-align: left;
}
.phase-badge {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  font-family: var(--font-display); font-weight: 700; font-size: 13px; color: #06101f;
}
.phase-title { min-width: 0; }
.phase-title h3 { font-size: 16px; font-weight: 600; }
.phase-title small { color: var(--text-3); font-size: 12.5px; }
.phase-pct { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.phase-caret { transition: transform .25s; color: var(--text-3); font-size: 14px; }
.phase.open .phase-caret { transform: rotate(180deg); }
.phase-head .track { grid-column: 1 / -1; }
.phase-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s ease; }
.phase.open .phase-body { grid-template-rows: 1fr; }
.phase-body > div { overflow: hidden; }
.steps { list-style: none; margin: 0; padding: 0 18px 18px 18px; display: flex; flex-direction: column; gap: 0; position: relative; }

.step {
  position: relative; display: grid; grid-template-columns: 24px 1fr; gap: 12px;
}
.step::before {
  content: ""; position: absolute; left: 11px; top: 28px; bottom: -4px; width: 2px; background: var(--line);
}
.step:last-child::before { display: none; }
.step-node {
  width: 24px; height: 24px; border-radius: 50%; margin-top: 16px; display: grid; place-items: center;
  border: 2px solid var(--slate); background: var(--bg-2); font-size: 11px; color: #04150a; font-weight: 800;
}
.step[data-status="termine"] .step-node { background: var(--green); border-color: var(--green); }
.step[data-status="en_cours"] .step-node { border-color: var(--amber); box-shadow: 0 0 0 4px rgba(245, 185, 66, 0.15); }
.step[data-status="en_cours"] .step-node::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); animation: pulse 1.6s ease-in-out infinite; }
.step[data-status="bloque"] .step-node { border-color: var(--red); background: rgba(239, 68, 68, .2); }
@keyframes pulse { 50% { transform: scale(.55); opacity: .6; } }

.step-card {
  margin: 8px 0; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line); text-align: left; width: 100%;
  display: flex; flex-direction: column; gap: 8px; transition: border-color .2s, transform .2s;
}
.step-card:hover { border-color: var(--line-strong); transform: translateX(3px); }
.step-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.step-top h4 { margin: 0; font-size: 15px; font-weight: 600; font-family: var(--font-body); }
.step-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-3); }
.step-meta span { white-space: nowrap; }
.step-progress { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }

.status {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.status.termine { color: var(--green); background: rgba(34, 197, 94, 0.12); }
.status.en_cours { color: var(--amber); background: rgba(245, 185, 66, 0.12); }
.status.a_venir { color: var(--text-2); background: rgba(100, 116, 139, 0.2); }
.status.bloque { color: #fca5a5; background: rgba(239, 68, 68, 0.15); }

.step.flash .step-card { animation: flash 2.4s ease; }
@keyframes flash { 0%, 40% { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(45, 212, 191, .25); } 100% { box-shadow: none; } }
.step.is-hidden { display: none; }
.phase.is-empty { display: none; }
.empty-msg { color: var(--text-3); font-size: 14px; padding: 8px 2px; }

/* ---------- Milestones / news ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.two-col .block { margin-top: 22px; }
.milestones { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.milestone { display: grid; grid-template-columns: 18px 1fr auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.milestone:last-child { border-bottom: 0; }
.ms-diamond { width: 12px; height: 12px; margin-top: 5px; transform: rotate(45deg); border: 2px solid var(--slate); border-radius: 2px; }
.milestone.done .ms-diamond { background: var(--green); border-color: var(--green); }
.milestone.next .ms-diamond { border-color: var(--teal); background: rgba(45, 212, 191, .25); box-shadow: 0 0 12px rgba(45, 212, 191, .6); }
.milestone b { font-weight: 600; font-size: 14px; }
.milestone small { display: block; color: var(--text-3); font-size: 12.5px; }
.ms-tag { font-size: 12px; font-weight: 700; color: var(--text-3); white-space: nowrap; }
.milestone.done .ms-tag { color: var(--green); }
.milestone.next .ms-tag { color: var(--teal); }

.news { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.news li { padding-left: 14px; border-left: 2px solid var(--line-strong); }
.news time { font-size: 12px; color: var(--teal); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.news b { display: block; font-size: 14.5px; margin: 2px 0; }
.news p { margin: 0; color: var(--text-2); font-size: 13.5px; }

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 18px var(--gutter); padding-bottom: max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); color: var(--text-3); font-size: 13px;
  max-width: 1240px; margin: 0 auto;
}
.footer strong { color: var(--text-2); }

/* ---------- Dialog ---------- */
.dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  padding: 24px; border-radius: 22px; border: 1px solid var(--line-strong);
  background: var(--surface-solid); color: var(--text); box-shadow: 0 40px 80px -20px #000;
}
.dialog::backdrop { background: rgba(3, 7, 15, 0.7); backdrop-filter: blur(4px); }
.dialog[open] { animation: pop .28s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.dialog-close { position: absolute; top: 12px; right: 12px; margin: 0; }
.dialog-close button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); }
.dialog h3 { font-size: 20px; padding-right: 40px; margin: 10px 0 8px; }
.dialog p { color: var(--text-2); margin: 0 0 16px; }
.dialog dl { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin: 0 0 16px; }
.dialog dl div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.dialog dt { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }
.dialog dd { margin: 2px 0 0; font-weight: 600; font-size: 14px; }
.dialog h5 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.dialog ul.deliv { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.dialog ul.deliv li { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; }
.dialog ul.deliv li::before { content: "◆ "; color: var(--teal); font-size: 10px; }

/* ---------- Toast & error ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 140%); opacity: 0;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--teal); color: #04201c; box-shadow: 0 12px 30px -8px rgba(45, 212, 191, .6);
  transition: transform .4s cubic-bezier(.2,.9,.3,1.2), opacity .3s; max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.error-screen { position: fixed; inset: 0; z-index: 60; display: grid; place-content: center; text-align: center; gap: 6px; padding: 24px; background: var(--bg); }
.error-screen[hidden] { display: none; }
.error-screen small { color: var(--text-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .flow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .flow-step:nth-child(3)::after { display: none; }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-3d { max-width: 380px; order: -1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phases-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .live #liveText { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand-text small { display: none; }
  .hero-meta { grid-template-columns: 1fr 1fr; }
  .hero-meta div:last-child { grid-column: 1 / -1; }
  .flow { grid-template-columns: 1fr; }
  .flow-step { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
  .flow-step .flow-num { margin: 0; }
  .flow-step span:last-child { flex-basis: 100%; padding-left: 40px; }
  .flow-step::after { display: none !important; }
  .bars-wrap { aspect-ratio: 4 / 3; }
  .phase-head { padding: 14px; gap: 10px; }
  .steps { padding: 0 12px 14px; }
  .dialog dl { grid-template-columns: 1fr; }
  .kpi { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
