@font-face { font-family: 'DM Sans'; src: url(fonts/dm-sans.ttf) format('truetype'); font-weight: 100 1000; font-display: swap; }
@font-face { font-family: 'Instrument Serif'; src: url(fonts/instrument-serif.ttf) format('truetype'); font-display: swap; }

:root {
  /* Encre : neutres légèrement chauds, comme la pénombre d'une église en brique. */
  --ink-0: #0f0e0c; --ink-1: #171512; --ink-2: #1f1c18; --ink-3: #2a2620;
  --line: rgba(239, 231, 214, 0.09); --line-2: rgba(239, 231, 214, 0.16);
  --ivory: #efe7d6; --ivory-2: #bdb4a3; --ivory-3: #8a8276;
  --gold: #c9a55c;              /* or patiné : seul accent */
  --gold-dim: rgba(201, 165, 92, 0.16);
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --r-ctl: 8px; --r-card: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink-0); color: var(--ivory); font: 400 14px/1.5 var(--sans); }
body { display: grid; grid-template-rows: 56px 1fr; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ivory); text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; }
.muted { color: var(--ivory-3); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ——— En-tête */
.top { display: flex; align-items: center; gap: 24px; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--ink-0); }
.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand .mark { width: 10px; height: 10px; background: var(--gold); align-self: center; transform: rotate(4deg); border-radius: 1px; }
.brand .name { font: 24px/1 var(--serif); }
.brand .sub { color: var(--ivory-3); font-size: 13px; }
.acts { display: flex; gap: 4px; margin: 0 auto; }
.acts button { display: flex; align-items: baseline; gap: 8px; height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-ctl); background: none; color: var(--ivory-2); cursor: pointer; transition: background-color .15s var(--ease), color .15s var(--ease); }
.acts button:hover { background: var(--ink-2); color: var(--ivory); }
.acts button[aria-current] { background: var(--ink-2); color: var(--ivory); box-shadow: inset 0 -2px 0 var(--gold); }
.acts .n { font: 18px/1 var(--serif); color: var(--ivory-3); }
.acts button[aria-current] .n { color: var(--gold); }
.tools { display: flex; gap: 8px; }

/* ——— Boutons */
button { cursor: pointer; }
.ghost, .seg button, .actions button, .chip { height: 32px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--line-2); background: var(--ink-1); color: var(--ivory-2); transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease); }
.ghost:hover, .seg button:hover, .actions button:hover { background: var(--ink-3); color: var(--ivory); }
.small.ghost, button.small { height: 28px; font-size: 12px; padding: 0 10px; }
.primary { background: var(--ivory) !important; color: var(--ink-0) !important; border-color: var(--ivory) !important; font-weight: 500; }
.primary:hover { background: #fff !important; }
.primary:disabled { opacity: .4; cursor: not-allowed; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--ink-1); border: 1px solid var(--line); }
.seg button { border: 0; background: none; height: 28px; }
.seg button.on { background: var(--ink-3); color: var(--ivory); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg.col { display: grid; }
.seg.col button { text-align: left; }
.link { border: 0; background: none; padding: 0; color: var(--ivory); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }

/* ——— Structure */
main { display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
#stage { position: relative; min-height: 0; overflow: hidden; background: var(--ink-0); }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#cartel { border-left: 1px solid var(--line); background: var(--ink-1); overflow: auto; padding: 24px; display: flex; flex-direction: column; gap: 24px; }
.act { position: absolute; inset: 0; display: none; pointer-events: none; }
.act > * { pointer-events: auto; }
.act-1 .act1, .act-2 .act2, .act-3 .act3, .act-4 .act4 { display: block; }
.act-2 #gl, .act-4 #gl { visibility: hidden; }
.act2, .act4 { background: var(--ink-0); overflow: auto; }

/* ——— Cartel */
#card h2 { font: 30px/1.1 var(--serif); margin: 4px 0 10px; letter-spacing: 0; }
#card p { margin: 10px 0; color: var(--ivory-2); }
#card .note { color: var(--ivory-3); border-left: 2px solid var(--line-2); padding-left: 10px; font-size: 13px; }
.kicker { margin: 0; color: var(--ivory-3); font-size: 12px; }
.status { display: inline-flex; gap: 6px; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-2); font-size: 12px; color: var(--ivory-2); white-space: nowrap; }
.status.s-atteste span { color: var(--gold); }
.sources { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.sources summary { color: var(--ivory-3); font-size: 12px; cursor: pointer; }
.src { padding-left: 18px; margin: 8px 0 0; font-size: 12px; color: var(--ivory-3); }
.src li + li { margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
#panel h3 { font: 500 13px/1.3 var(--sans); color: var(--ivory-2); margin: 18px 0 8px; }

/* ——— Acte I */
.caption { position: absolute; left: 24px; top: 20px; max-width: 520px; font: 22px/1.25 var(--serif); color: var(--ivory); text-shadow: 0 1px 12px rgba(0,0,0,.6); }
.bar { position: absolute; left: 24px; right: 24px; bottom: 20px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-start; padding-right: 260px; }
.bar label { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 10px; background: var(--ink-1); border: 1px solid var(--line); color: var(--ivory-2); }
.bar .seg span { padding: 0 8px; color: var(--ivory-2); align-self: center; }
body:not([data-mode="tour"]) .tour-only { display: none; }
body:not([data-mode="maquette"]) .cut-only { display: none !important; }
.plan { position: absolute; right: 20px; bottom: 20px; width: 236px; margin: 0; padding: 8px; border-radius: var(--r-card); background: rgba(23, 21, 18, .92); border: 1px solid var(--line); }
.plan svg { display: block; width: 100%; height: auto; background: #e9e3d6; border-radius: 6px; cursor: crosshair; }
.plan figcaption { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px 0; font-size: 12px; color: var(--ivory-2); }
.plan-model { fill: none; stroke: #6b4a14; stroke-width: 1.6; }
.plan-model.thin { stroke-width: .8; stroke-dasharray: 3 2; }
.plan-spot { fill: #fff; stroke: #6b4a14; stroke-width: 1.5; cursor: pointer; }
.plan-spot:hover, .plan-spot:focus { fill: #c9a55c; }
.plan-me { fill: #121110; stroke: #fff; stroke-width: 1.5; }
.plan-cone { fill: rgba(18, 17, 16, .28); }
.plan-scale { stroke: #121110; stroke-width: 2; }
.plan-scale-t { font: 10px var(--sans); fill: #121110; }
#labels { position: absolute; inset: 0; pointer-events: none; }
.pin { position: absolute; left: 0; top: 0; pointer-events: auto; height: 26px; padding: 0 10px; margin: -13px 0 0 0; border-radius: 13px; border: 1px solid var(--line-2); background: rgba(15,14,12,.85); color: var(--ivory); font-size: 12px; white-space: nowrap; }
.pin:hover { border-color: var(--gold); }

/* ——— Acte II */
.rd-tools { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 16px 24px; background: var(--ink-0); border-bottom: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; font-size: 13px; }
.chip input { accent-color: var(--gold); margin: 0; }
.rd-view { display: grid; gap: 20px; padding: 20px 24px 32px; }
.rd-view.n2 { grid-template-columns: 1fr 1fr; align-items: start; }
.rd-panel { margin: 0; }
.rd-frame { position: relative; overflow: hidden; border-radius: var(--r-card); background: #000; cursor: zoom-in; touch-action: none; }
.rd-zoom { position: relative; transform-origin: 0 0; will-change: transform; }
.rd-zoom img { display: block; width: 100%; height: auto; user-select: none; }
.rd-zoom svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.zone { fill: rgba(15, 14, 12, 0); stroke: rgba(255, 250, 238, .42); stroke-width: 1.25; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .15s var(--ease), stroke .15s var(--ease); }
.zone.s-interpretation { stroke-dasharray: 7 5; }
.zone.s-reconstruction { stroke-dasharray: 2 4; }
line.zone { stroke-width: 1.25; }
.zone:hover, .zone:focus { fill: rgba(15, 14, 12, .18); stroke: rgba(255, 250, 238, .95); stroke-width: 2; outline: none; }
.zone.sel { stroke: var(--ivory); stroke-width: 2.5; fill: rgba(15, 14, 12, .12); }
.rd-frame:hover .zone:not(.sel):not(:hover) { stroke: rgba(255, 250, 238, .6); }
.rd-panel figcaption { display: flex; gap: 12px; align-items: center; padding: 10px 2px; }
.rd-panel figcaption .t { font: 20px/1 var(--serif); }
.rd-panel figcaption .muted { font-size: 12px; margin-right: auto; }
.rd-compare { margin: 0 24px 32px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--ink-1); }
.rd-compare table { width: 100%; border-collapse: collapse; }
.rd-compare caption { text-align: left; font: 22px var(--serif); padding-bottom: 8px; }
.rd-compare th, .rd-compare td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.rd-compare thead th { color: var(--ivory-3); font-weight: 500; font-size: 12px; }
.dossier h3 { font: 22px/1.2 var(--serif) !important; color: var(--ivory) !important; margin: 4px 0 12px !important; }
.indices { padding-left: 18px; margin: 0 0 12px; }
.indices li { margin: 6px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: grid; gap: 6px; color: var(--ivory-2); font-size: 13px; }
textarea { width: 100%; resize: vertical; padding: 10px 12px; border-radius: var(--r-ctl); border: 1px solid var(--line-2); background: var(--ink-0); line-height: 1.5; }
.checks { list-style: none; padding: 0; margin: 12px 0; font-size: 13px; color: var(--ivory-3); }
.checks li { display: flex; gap: 8px; margin: 4px 0; }
.checks li.ok { color: var(--ivory-2); }
.checks li.ok span { color: var(--gold); }

/* ——— Acte III */
#lab2d { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.no-gl.act-3 #lab2d { display: block; }
.lab-hud { position: absolute; left: 24px; top: 20px; display: flex; gap: 16px; font: 12px var(--mono); color: var(--ivory-2); }
.lab-split { position: absolute; left: 50%; top: 48px; bottom: 24px; border-left: 1px solid var(--line-2); display: none; }
body[data-lab="experience"].act-3 .lab-split { display: block; }
.lab-split span { position: absolute; top: 0; font: 12px var(--mono); color: var(--ivory-2); white-space: nowrap; }
.lab-split .a { right: 12px; } .lab-split .b { left: 12px; }
.lab-panel .seg { margin-bottom: 8px; }
.range { grid-template-columns: 130px 1fr 56px; align-items: center; gap: 10px; margin: 6px 0; }
.range output { text-align: right; color: var(--ivory-2); }
input[type=range] { accent-color: var(--gold); width: 100%; }
.check { grid-template-columns: auto 1fr; align-items: center; }
.coupe-svg { width: 100%; height: auto; margin-top: 10px; border-radius: var(--r-ctl); background: #100f0d; border: 1px solid var(--line); }
.svg-t { font: 11px var(--sans); fill: #bdb4a3; }
.svg-t.dark { fill: #171512; }
.svg-normal { stroke: #8a8276; stroke-dasharray: 3 3; }
.svg-ray { fill: none; stroke: #efe7d6; stroke-width: 2; }
.svg-ray.thin { stroke-width: 1.5; }
.svg-ray.gold { stroke: #c9a55c; }
.calc { color: var(--ivory-2); }
.steps { padding-left: 18px; margin: 8px 0; }
.steps li { margin: 10px 0; color: var(--ivory-2); }
.steps b { display: block; color: var(--ivory); font-weight: 500; margin-bottom: 4px; }
.measure { border-collapse: collapse; margin-top: 8px; font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.measure th, .measure td { padding: 4px 10px 4px 0; text-align: right; }
.measure th:first-child { text-align: left; font-family: var(--sans); font-weight: 400; }

/* ——— Acte IV */
.hi { padding: 32px 40px; max-width: 1100px; }
.hi-head h2 { font: 40px/1.1 var(--serif); margin: 4px 0 8px; }
.frise { position: relative; height: 56px; margin: 28px 0 36px; border-bottom: 1px solid var(--line-2); }
.axis span { position: absolute; bottom: -24px; transform: translateX(-50%); font: 12px var(--mono); color: var(--ivory-3); }
.band { position: absolute; bottom: 0; height: 100%; background: rgba(239, 231, 214, .05); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.band span { position: absolute; top: 4px; left: 6px; font-size: 11px; color: var(--ivory-3); white-space: nowrap; }
.dot { position: absolute; bottom: -5px; width: 10px; height: 10px; margin-left: -5px; background: var(--ink-0); border: 1.5px solid var(--ivory-2); transform: rotate(45deg); }
.dot.s-atteste { background: var(--gold); border-color: var(--gold); }
.dot.sel { outline: 2px solid var(--ivory); outline-offset: 2px; }
.ev-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.ev { width: 100%; display: grid; grid-template-columns: 96px 1fr auto; gap: 16px; align-items: center; text-align: left; height: 44px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid transparent; background: none; color: var(--ivory); }
.ev:hover { background: var(--ink-1); }
.ev.sel { background: var(--ink-2); border-color: var(--line-2); }
.ev .d { color: var(--ivory-2); }
.notions { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 48px; }
.notion { display: grid; gap: 8px; justify-items: start; text-align: left; padding: 16px; border-radius: var(--r-card); border: 1px solid var(--line); background: var(--ink-1); color: var(--ivory-2); }
.notion .t { font: 22px/1.1 var(--serif); color: var(--ivory); }
.notion:hover { border-color: var(--line-2); background: var(--ink-2); }

/* ——— Transitions, dialogues, sans WebGL */
#veil { position: fixed; inset: 56px 0 0 0; background: var(--ink-0); opacity: 0; pointer-events: none; transition: opacity .4s var(--ease); z-index: 20; }
#veil.on { opacity: 1; }
dialog { max-width: 920px; width: calc(100vw - 32px); max-height: calc(100vh - 64px); padding: 0; border: 1px solid var(--line-2); border-radius: 16px; background: var(--ink-1); color: var(--ivory); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--ink-1); }
.dlg-head h2 { font: 28px var(--serif); margin: 0; }
.docs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; padding: 24px; }
.docs-grid figure { margin: 0; }
.docs-grid img { width: 100%; height: 180px; object-fit: cover; border-radius: var(--r-ctl); background: #e9e3d6; }
.docs-grid figcaption { font-size: 12px; color: var(--ivory-2); margin-top: 6px; }
.help-body { padding: 8px 24px 24px; }
.help-body h3 { font: 500 13px var(--sans); color: var(--ivory-3); margin: 20px 0 8px; }
.keys, .status-legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; color: var(--ivory-2); }
kbd { display: inline-block; min-width: 22px; height: 22px; padding: 0 6px; margin-right: 3px; border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--ink-0); font: 12px/20px var(--mono); text-align: center; color: var(--ivory); }
.rm { display: flex; gap: 8px; align-items: center; margin-top: 16px; color: var(--ivory-2); }
.nogl-note { position: absolute; left: 24px; top: 20px; right: 24px; padding: 10px 14px; border-radius: var(--r-ctl); border: 1px solid var(--line-2); background: var(--ink-1); color: var(--ivory-2); font-size: 13px; z-index: 3; }
.nogl-photos { display: none; }
.no-gl .act1 .caption, .no-gl .act1 .bar, .no-gl #labels { display: none; }
.no-gl .act1 { overflow: auto; }
.no-gl .act1 .nogl-photos { display: grid; gap: 16px; position: absolute; right: 24px; top: 76px; width: calc(50% - 48px); }
.no-gl .act1 .nogl-photos figure { margin: 0; }
.no-gl .act1 .nogl-photos img { width: 100%; height: 26vh; object-fit: cover; border-radius: var(--r-card); }
.no-gl .act1 .nogl-photos figcaption { font-size: 12px; color: var(--ivory-3); margin-top: 4px; }
.no-gl .act1 .plan { left: 24px; right: auto; top: 76px; bottom: 24px; width: auto; aspect-ratio: 382 / 470; }
.no-gl .act1 .plan svg { height: calc(100% - 28px); width: auto; margin: 0 auto; }
.no-gl.act-1 .nogl-note, .no-gl.act-3 .nogl-note { display: block; }
.no-gl.act-2 .nogl-note, .no-gl.act-4 .nogl-note { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition-duration: 0s !important; } }

/* ——— Petits écrans : le cartel passe sous la scène. */
@media (max-width: 960px) {
  body { overflow: auto; grid-template-rows: auto 1fr; }
  .top { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .acts { order: 3; width: 100%; overflow-x: auto; margin: 0; }
  .acts { scrollbar-width: none; }
  .acts button { white-space: nowrap; padding: 0 10px; flex: none; }
  .acts .l { font-size: 13px; }
  .acts button:not([aria-current]) .l { display: none; }
  .tools { margin-left: auto; }
  .top { flex-wrap: wrap; }
  .brand .sub { display: none; }
  main { grid-template-columns: 1fr; grid-template-rows: 62vh auto; }
  #cartel { border-left: 0; border-top: 1px solid var(--line); padding: 20px 16px; }
  .caption { left: 16px; right: 16px; font-size: 18px; }
  .bar { left: 16px; right: 16px; bottom: 12px; padding-right: 0; }
  .plan { width: 132px; top: 64px; bottom: auto; right: 12px; }
  .plan figcaption { display: none; }
  .rd-view.n2 { grid-template-columns: 1fr; }
  .rd-tools { padding: 12px 16px; }
  .hi { padding: 24px 16px; }
  .ev { grid-template-columns: 72px 1fr; height: auto; padding: 8px 10px; }
  .ev .status { grid-column: 2; justify-self: start; }
}
