/* De l'esquisse au rendu — démo Forge Labs. S'appuie sur ../_shared/demo.css et ../_shared/archi.css. */

:root {
  --paper: #fbfbf8;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, "P052", "URW Palladio L", Georgia, "Noto Serif", serif;
  --text: var(--ink);
  --text-muted: var(--muted);
}

/* ---------- Mise en page ---------- */
.er { max-width: 1320px; margin: 0 auto; padding: 28px var(--gutter) 48px; }
.er h1 { font-size: clamp(1.6rem, 3vw, 2.4rem); max-width: 22em; margin: 10px 0 10px; }
.intro .lead { font-size: clamp(1rem, 1.4vw, 1.12rem); max-width: 60rem; margin-bottom: 18px; }

.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 10px; padding: 0; margin: 0 0 26px; }
.steps li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: rgba(255, 255, 255, .6); border: 1px solid var(--line); font-size: .88rem; color: var(--muted); transition: background .3s ease, color .3s ease, border-color .3s ease; }
.steps li span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--beton-200); color: var(--slate-800); font: 700 .78rem/1 var(--font-body); }
.steps li.is-on { color: var(--ink); border-color: rgba(47, 62, 74, .35); background: #fff; }
.steps li.is-on span { background: var(--slate-800); color: #fff; }

.stage { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "view intent" "notice intent"; gap: 22px 26px; align-items: start; margin-bottom: 40px; }
.view-col { grid-area: view; min-width: 0; }
.intent { grid-area: intent; }
.notice-col { grid-area: notice; min-width: 0; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 1px 2px rgba(20, 27, 33, .05), 0 14px 34px -18px rgba(20, 27, 33, .28); }
.panel-head h2 { font-size: 1.22rem; margin: 0 0 6px; }
.panel-head p { margin: 0 0 16px; }

.btn-soft { background: #fff; color: var(--slate-800); border-color: rgba(47, 62, 74, .3); min-height: 44px; padding: .65em 1.1em; font-size: .94rem; }
.btn-soft:hover:not(:disabled) { background: var(--slate-100); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Visionneuse ---------- */
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.view-head h2 { font-size: clamp(1.05rem, 1.6vw, 1.3rem); margin: 0; }
.view-head .fict { display: block; font-size: .78rem; margin-top: 4px; font-weight: 500; }

.viewer { position: relative; aspect-ratio: 3 / 2; border-radius: 14px; overflow: hidden; background: var(--calque-50); border: 1px solid rgba(47, 62, 74, .22); box-shadow: 0 1px 2px rgba(20, 27, 33, .06), 0 22px 50px -26px rgba(20, 27, 33, .45); touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.viewer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.sk { animation: sk-in 1s ease both; }
@keyframes sk-in { from { opacity: 0; filter: blur(2px); } to { opacity: 1; filter: none; } }

.rd { position: absolute; inset: 0; visibility: hidden; }
.viewer[data-state="dev"] .rd, .viewer[data-state="ready"] .rd { visibility: visible; }
.viewer[data-state="ready"] .rd { clip-path: inset(0 0 0 var(--pos, 50%)); -webkit-clip-path: inset(0 0 0 var(--pos, 50%)); }
.rv { opacity: 0; transition: opacity .75s ease; }
.rv.on { opacity: 1; }

.scan { position: absolute; top: 0; bottom: 0; left: 0; width: 140px; margin-left: -70px; pointer-events: none; opacity: 0; background: linear-gradient(90deg, transparent, rgba(255, 247, 222, .55) 45%, rgba(255, 255, 255, .85) 50%, rgba(255, 247, 222, .55) 55%, transparent); mix-blend-mode: screen; }
.viewer[data-state="dev"] .scan { opacity: 1; }

.lbl { position: absolute; top: 12px; padding: 5px 10px; border-radius: 999px; font: 600 .76rem/1.2 var(--font-body); letter-spacing: .02em; pointer-events: none; transition: opacity .3s ease; }
.lbl-l { left: 12px; background: rgba(251, 251, 248, .92); color: var(--slate-900); border: 1px solid rgba(47, 62, 74, .25); }
.lbl-r { right: 12px; background: rgba(28, 38, 46, .82); color: #fff; opacity: 0; }
.viewer[data-state="ready"] .lbl-r { opacity: 1; }

.handle { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 44px; margin-left: -22px; display: none; cursor: ew-resize; touch-action: none; }
.handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(20, 27, 33, .25), 0 0 14px rgba(20, 27, 33, .35); }
.knob { position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--slate-800); box-shadow: 0 4px 16px rgba(20, 27, 33, .35); border: 1px solid rgba(47, 62, 74, .25); transition: transform .15s ease; }
.viewer[data-state="ready"] .handle { display: block; }
.handle:focus-visible { outline: none; }
.handle:focus-visible .knob { outline: 3px solid var(--focus); outline-offset: 2px; }
.viewer.dragging .knob { transform: scale(1.08); }
.viewer[data-state="ready"] { cursor: ew-resize; }

.dev-status { position: absolute; left: 12px; bottom: 12px; margin: 0; max-width: calc(100% - 24px); padding: 7px 12px; border-radius: 10px; background: rgba(28, 38, 46, .86); color: #fff; font: 500 .82rem/1.35 var(--font-body); opacity: 0; transform: translateY(6px); transition: opacity .25s ease, transform .25s ease; pointer-events: none; }
.dev-status.show { opacity: 1; transform: none; }
.dev-status .bar { display: block; height: 3px; margin-top: 6px; border-radius: 2px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.dev-status .bar i { display: block; height: 100%; width: 0; background: var(--verif-200); }

.view-hint { margin: 10px 2px 0; }

.guards { list-style: none; margin: 14px 0 0; padding: 12px 14px; display: grid; gap: 8px; background: var(--verif-100); border: 1px solid var(--verif-200); border-radius: 12px; color: #3f2d06; font-size: .9rem; line-height: 1.45; }
.guards li { display: flex; gap: 10px; align-items: flex-start; }
.guards svg { flex: none; margin-top: 2px; color: #8a5d05; }

/* ---------- Intentions ---------- */
.variants { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.variants legend { font: 600 .8rem/1.2 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--slate-600); margin-bottom: 8px; padding: 0; }
.vopt { position: relative; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--calque-50); transition: border-color .2s ease, background .2s ease, box-shadow .2s ease; }
.vopt:hover { border-color: rgba(47, 62, 74, .4); }
.vopt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.vopt:has(input:checked) { border-color: var(--slate-800); background: #fff; box-shadow: inset 0 0 0 1px var(--slate-800); }
.vopt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.vopt .sw { flex: none; width: 34px; height: 34px; border-radius: 8px; border: 1px solid rgba(20, 27, 33, .18); }
.sw-enduit { background: linear-gradient(135deg, #f1ebdd, #e3dccb); }
.sw-bois { background: repeating-linear-gradient(90deg, #d8b98a 0 5px, #c9a674 5px 6px, #dfc49a 6px 11px, #c49f6b 11px 12px); }
.sw-pierre { background: linear-gradient(#efe9dc 0 50%, transparent 50%), repeating-linear-gradient(0deg, #d9ccb1 0 6px, #c7b896 6px 7px); background-size: 100% 100%, 100% 100%; }
.vopt .vt { display: grid; gap: 2px; min-width: 0; }
.vopt strong { font-size: .95rem; }
.vopt small { color: var(--muted); font-size: .8rem; line-height: 1.3; }
.vopt .chk { margin-left: auto; flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--beton-300); }
.vopt:has(input:checked) .chk { border-color: var(--slate-800); background: radial-gradient(circle, var(--slate-800) 0 4px, transparent 5px); }

.vnote { border-left: 3px solid var(--slate-800); background: var(--calque-50); border-radius: 0 10px 10px 0; padding: 10px 12px; margin: 0 0 16px; font-size: .86rem; line-height: 1.45; }
.vnote dl { margin: 0; display: grid; gap: 6px; }
.vnote dt { font-weight: 700; color: var(--slate-800); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
.vnote dd { margin: 0; }
.vnote ul { margin: 2px 0 0; padding-left: 1.1em; }
.vnote.flash { animation: flash 1s ease; }
@keyframes flash { from { background: var(--slate-100); } to { background: var(--calque-50); } }

.params { margin: 0 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; border-top: 1px solid var(--line); }
.params div { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .84rem; line-height: 1.35; }
.params dt { color: var(--slate-600); font-weight: 600; font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; }
.params dd { margin: 0; }
.params-note { margin: 8px 0 0; font-size: .8rem; }

.vnote { margin-top: 16px; margin-bottom: 0; }
.btn-gen { width: 100%; min-height: 52px; font-size: 1.02rem; }
.btn-gen[aria-busy="true"] { opacity: .75; cursor: progress; }

.rules { margin-top: 16px; font-size: .86rem; border-top: 1px solid var(--line); padding-top: 12px; }
.rules summary { cursor: pointer; font-weight: 600; color: var(--slate-800); min-height: 32px; display: flex; align-items: center; }
.rules ul { margin: 8px 0 0; padding-left: 1.1em; display: grid; gap: 6px; color: var(--muted); }

/* Raccourci de variante sous la visionneuse (écrans étroits) */
.vquick { display: none; gap: 6px; margin-top: 10px; }
.vquick button { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 6px 8px; border-radius: 10px; border: 1px solid rgba(47, 62, 74, .28); background: #fff; color: var(--slate-800); font: 600 .84rem/1.2 var(--font-body); cursor: pointer; }
.vquick button[aria-pressed="true"] { background: var(--slate-800); color: #fff; border-color: var(--slate-800); }

/* ---------- Notice ---------- */
.notice { position: relative; background: var(--paper); border: 1px solid rgba(47, 62, 74, .2); border-radius: 6px; padding: clamp(20px, 3vw, 34px) clamp(18px, 3.4vw, 40px); box-shadow: 0 1px 2px rgba(20, 27, 33, .05), 0 18px 40px -24px rgba(20, 27, 33, .35); font-family: var(--serif); color: #1d2328; }
.notice::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--slate-800); border-radius: 6px 0 0 6px; }
.notice-kicker { font: 600 .74rem/1.2 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--slate-600); margin: 0 0 6px; }
.notice-head h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.2rem, 2vw, 1.5rem); letter-spacing: 0; margin: 0 0 4px; }
.notice-meta { font-family: var(--font-body); color: var(--muted); margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.notice-body { font-size: 1rem; line-height: 1.6; }
.notice-body h3 { font: 700 .8rem/1.2 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--slate-800); margin: 18px 0 6px; }
.notice-body h3:first-child { margin-top: 0; }
.notice-body p { margin: 0 0 .7em; }
.notice-body .verif { font-family: var(--font-body); font-size: .84rem; background: var(--verif-100); border: 1px dashed var(--verif-500); border-radius: 8px; padding: 8px 10px; color: #3f2d06; }
.notice-body .np { animation: np-in .5s ease both; }
.notice-body .changed { animation: changed 1.6s ease; }
@keyframes np-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes changed { 0% { background: rgba(246, 220, 156, .7); } 100% { background: transparent; } }
.notice-empty { font-family: var(--font-body); font-size: .95rem; }
.notice-foot { font-family: var(--font-body); color: var(--muted); margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- Planche imprimable : cachée à l'écran ---------- */
.planche { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "view" "intent" "notice"; }
  .vquick { display: flex; }
}
@media (max-width: 560px) {
  .er { padding-top: 20px; }
  .steps li { font-size: .8rem; padding: 4px 10px 4px 4px; }
  .steps li span { width: 22px; height: 22px; }
  .view-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .view-head .btn { order: 2; }
  .viewer { border-radius: 10px; }
  .lbl { top: 8px; font-size: .7rem; padding: 4px 8px; }
  .lbl-l { left: 8px; }
  .lbl-r { right: 8px; }
  .dev-status { left: 8px; bottom: 8px; font-size: .74rem; padding: 6px 9px; }
  .knob { width: 42px; height: 42px; margin: -21px 0 0 -21px; }
  .panel { padding: 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .sk, .notice-body .np, .notice-body .changed, .vnote.flash { animation: none !important; }
  .rv { transition: none; }
}

/* ---------- Impression : planche A4 paysage ---------- */
@page { size: A4 landscape; margin: 9mm; }
@media print {
  html, body { background: #fff !important; }
  body > *:not(.planche) { display: none !important; }
  .planche { display: grid !important; grid-template-rows: auto auto 1fr auto; gap: 4mm; width: 279mm; height: 191mm; overflow: hidden; color: #1d2328; font: 9pt/1.4 var(--serif); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pl-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: .6mm solid #2f3e4a; padding-bottom: 2.5mm; }
  .pl-head h2 { font: 600 16pt/1.1 var(--serif); margin: 0; letter-spacing: 0; }
  .pl-kicker { font: 600 7pt/1 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: #536a7c; margin: 0 0 1.5mm; }
  .pl-sub, .pl-date { font: 8.5pt/1.3 var(--font-body); color: #56626b; margin: 1mm 0 0; }
  .pl-images { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm; }
  .pl-images figure { margin: 0; }
  .pl-images img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border: .3mm solid #c9c6bc; display: block; }
  .pl-images figcaption { font: 600 7.5pt/1.2 var(--font-body); color: #3d5060; margin-top: 1.2mm; }
  .pl-notice { columns: 3; column-gap: 6mm; font-size: 7.6pt; line-height: 1.38; overflow: hidden; }
  .pl-notice h3 { font: 700 6.8pt/1.2 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: #2f3e4a; margin: 0 0 .8mm; break-after: avoid; }
  .pl-notice p { margin: 0 0 1.6mm; }
  .pl-notice .verif { font-family: var(--font-body); font-size: 6.8pt; border: .25mm dashed #c98a12; padding: 1mm 1.5mm; background: #fdf1d2; }
  .pl-foot { font: 7pt/1.3 var(--font-body); color: #4a3303; background: #fdf1d2; padding: 1.5mm 2.5mm; border-radius: 1mm; }
}
