/* Outil de plans Madone — styles */

@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('assets/fonts/dm-sans-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('assets/fonts/dm-sans-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('assets/fonts/dm-sans-latin-500-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('assets/fonts/dm-sans-latin-ext-500-normal.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('assets/fonts/dm-sans-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('assets/fonts/dm-sans-latin-ext-700-normal.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --ink: #111111;
  --ink-2: #3a3a3a;
  --muted: #6b6b6b;
  --line: #e4e1db;
  --line-strong: #cfcbc3;
  --bg: #f7f6f3;
  --card: #ffffff;
  --soft: #f1efea;
  --ok: #1f7a3a;
  --ok-bg: #eaf5ee;
  --warn: #9a4a00;
  --warn-bg: #fdf3e7;
  --error: #b42318;
  --error-bg: #fdecea;
  --todo: #e07b00;
  --radius: 12px;
  --radius-small: 8px;
  --shadow: 0 1px 2px rgb(17 17 17 / 4%), 0 8px 24px rgb(17 17 17 / 5%);
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; height: auto; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; text-align: center; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand img { width: 120px; height: auto; }
.topbar__title { flex: 1; min-width: 0; }
.topbar__title h1 { font-size: 18px; }
.topbar__save { font-size: 13px; color: var(--muted); min-height: 1.2em; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: #fff;
  font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background-color .15s, color .15s, border-color .15s;
}
.button:hover { background: #2b2b2b; }
.button[disabled], .button[aria-disabled='true'] { background: var(--line-strong); border-color: var(--line-strong); color: #fff; cursor: not-allowed; }
.button--ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.button--ghost:hover { background: var(--soft); border-color: var(--ink); }
.button--small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.button--large { min-height: 52px; padding: 0 28px; font-size: 16px; }
.icon-button {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; cursor: pointer;
}
.icon-button:hover:not([disabled]) { background: var(--soft); border-color: var(--ink); }
.icon-button[disabled] { opacity: .35; cursor: default; }
.icon-button svg { width: 18px; height: 18px; }
.link-button { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 500; }
.link-button--danger { color: var(--error); }

/* Stepper */
.stepper {
  display: flex; gap: 4px; padding: 0 32px; background: var(--card); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.stepper::-webkit-scrollbar { display: none; }
.step {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px 13px;
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
  color: var(--muted); font-weight: 500;
}
.step:hover { color: var(--ink); }
.step[aria-current='step'] { color: var(--ink); border-bottom-color: var(--ink); }
.step__num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; border: 1px solid var(--line-strong); background: var(--card);
}
.step[aria-current='step'] .step__num { background: var(--ink); border-color: var(--ink); color: #fff; }
.step--done .step__num { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.step--todo .step__num { border-color: var(--todo); color: var(--todo); }

/* Workspace */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(380px, 480px) minmax(0, 1fr);
  gap: 32px;
  padding: 32px;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}
.panel { min-width: 0; display: flex; flex-direction: column; gap: 40px; padding-bottom: 96px; }
.preview { position: sticky; top: 24px; align-self: start; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.section { display: flex; flex-direction: column; gap: 20px; }
.section__head { display: flex; flex-direction: column; gap: 6px; }
.section__head h2 { font-size: 24px; }
.section__head h3 { font-size: 17px; }
.lead { color: var(--ink-2); }
.hint { color: var(--muted); font-size: 13px; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; display: flex; flex-direction: column; gap: 20px; box-shadow: var(--shadow);
}
.card--flat { box-shadow: none; }
.card__head { display: flex; align-items: center; gap: 12px; }
.card__head h3 { font-size: 16px; flex: 1; }
.card__meta { color: var(--muted); font-size: 13px; }
.card__actions { display: flex; gap: 16px; flex-wrap: wrap; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.choice-grid--wide { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.choice {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left;
  padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card);
  cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.choice:hover { border-color: var(--ink); box-shadow: var(--shadow); }
.choice[aria-pressed='true'], .choice[aria-checked='true'] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice[aria-pressed='true']::after, .choice[aria-checked='true']::after {
  content: ''; position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/12px no-repeat;
}
.choice svg { width: 44px; height: 44px; color: var(--ink); }
.choice__text { display: flex; flex-direction: column; gap: 4px; padding-right: 18px; }
.choice__title { font-weight: 700; }
.choice__hint { font-size: 13px; color: var(--muted); line-height: 1.4; }
.choice--compact { flex-direction: row; align-items: center; gap: 12px; padding: 14px 16px; }
.choice--compact svg { width: 32px; height: 32px; flex: none; }

/* Fields */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 16px; }
.fields--one { grid-template-columns: minmax(0, 1fr); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field__label { font-size: 14px; font-weight: 500; }
.field__help { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--card); font-size: 15px;
}
.input--unit { padding-right: 46px; }
.input-wrap__unit { position: absolute; right: 14px; color: var(--muted); font-size: 13px; pointer-events: none; }
.textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.input[aria-invalid='true'] { border-color: var(--todo); box-shadow: 0 0 0 1px var(--todo); }
.select { appearance: none; padding-right: 40px; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%23111' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") right 14px center/14px no-repeat; }

.segmented { display: flex; flex-wrap: wrap; gap: 6px; }
.segmented button {
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--card); cursor: pointer; font-size: 14px; font-weight: 500;
}
.segmented button:hover { border-color: var(--ink); }
.segmented button[aria-checked='true'] { background: var(--ink); border-color: var(--ink); color: #fff; }
.segmented--todo button { border-color: var(--todo); }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--ink); flex: none; }
.subfields { padding: 16px; border-radius: 10px; background: var(--soft); }

.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 10px; background: var(--soft); font-size: 14px; color: var(--ink-2); }
.callout svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.callout--warn { background: var(--warn-bg); color: var(--warn); }

/* Explanations */
.howto { margin: 0; padding: 0; list-style: none; counter-reset: howto; display: flex; flex-direction: column; gap: 10px; }
.howto li { counter-increment: howto; display: flex; gap: 12px; align-items: baseline; color: var(--ink-2); }
.howto li::before {
  content: counter(howto); flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; transform: translateY(5px);
}
.howto strong { color: var(--ink); }
.diagram { margin: 0; padding: 16px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.diagram svg { width: 100%; max-width: 360px; height: auto; display: block; margin: 0 auto; }
.diagram figcaption { font-size: 12.5px; color: var(--muted); text-align: center; }
.legend-list { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.legend-list > div { padding: 12px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.legend-list dt { font-weight: 700; }
.legend-list dd { margin: 2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.4; }

/* Pieces & edges */
.piece-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--card); cursor: pointer; font-weight: 500; font-size: 14px;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed='true'] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--todo); }
.chip[aria-pressed='true'] .chip__dot { background: #ffb357; }

.piece-card[aria-expanded='false'] { cursor: pointer; }
.piece-card[aria-expanded='false']:hover { border-color: var(--ink); }
.piece-card__summary { display: flex; align-items: center; gap: 14px; }
.piece-card__summary svg { width: 36px; height: 36px; flex: none; }
.piece-card__text { flex: 1; min-width: 0; }
.piece-card__title { font-weight: 700; }
.piece-card__dims { color: var(--muted); font-size: 13px; }

.edge-list { display: flex; flex-direction: column; gap: 4px; }
.edge-row {
  display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 10px; border: 1px solid transparent;
}
.edge-row:hover, .edge-row--active { background: var(--soft); }
.edge-row--todo .edge-row__label::after { content: ' · à choisir'; color: var(--todo); font-weight: 500; }
.edge-row__label { font-weight: 500; }
.edge-row--flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { border-color: var(--ink); background: var(--soft); } 100% { border-color: transparent; } }

/* Issues */
.status { display: flex; align-items: center; gap: 14px; padding: 20px; border-radius: var(--radius); }
.status svg { width: 28px; height: 28px; flex: none; }
.status--ok { background: var(--ok-bg); color: var(--ok); }
.status--todo { background: var(--warn-bg); color: var(--warn); }
.status strong { display: block; font-size: 17px; }
.issue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.issue { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.issue::before { content: ''; width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--warn); }
.issue--error::before { background: var(--error); }
.issue__text { flex: 1; }

.summary-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.summary-table th, .summary-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.summary-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 500; }

/* Preview */
.preview__bar { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.preview__title { font-weight: 700; }
.preview__canvas {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; min-height: 280px; display: grid; place-items: center; position: relative;
}
.preview__canvas > div:not(.popover) { width: 100%; display: flex; justify-content: center; }
.preview__canvas svg { width: 100%; height: auto; max-height: calc(100vh - 260px); }
.preview__empty { color: var(--muted); text-align: center; max-width: 320px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.preview__empty svg { width: 56px; height: 56px; color: var(--line-strong); }
.preview__legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); }
.preview__legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.preview__canvas .hit { cursor: pointer; pointer-events: stroke; }
.preview__canvas .hit:hover, .preview__canvas .hit--active { stroke: rgb(17 17 17 / 12%); }
.preview__canvas [data-cutout], .preview__canvas text[data-edge] { cursor: pointer; }
.preview__canvas .todo { pointer-events: none; }
.sheet-pages { display: flex; flex-direction: column; gap: 20px; width: 100%; }
.sheet-page { background: #fff; border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow); }
.sheet-page svg { width: 100%; height: auto; display: block; max-height: none; }

.popover {
  position: absolute; z-index: 10; display: flex; flex-direction: column; gap: 4px; padding: 8px; min-width: 220px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgb(17 17 17 / 16%);
}
.popover__title { font-size: 12px; color: var(--muted); padding: 4px 8px 6px; }
.popover button { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 9px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; max-width: 280px; }
.popover button span { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.popover button:hover, .popover button[aria-checked='true'] { background: var(--soft); }

/* Pager */
.pager {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 32px calc(14px + env(safe-area-inset-bottom));
  background: rgb(255 255 255 / 94%); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.pager__info { color: var(--muted); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}

.download { display: flex; flex-direction: column; gap: 16px; }

/* Mobile */
@media (max-width: 960px) {
  body { font-size: 15px; }
  .topbar { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  .brand img { width: 96px; }
  .topbar__title { order: 3; flex-basis: 100%; }
  .topbar__title h1 { font-size: 16px; }
  .topbar__actions { margin-left: auto; }
  .topbar__actions .button span { font-size: 13px; }
  .stepper { padding: 0 8px; }
  .step { padding: 12px 10px; gap: 8px; font-size: 14px; }
  .workspace { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 20px; }
  .preview { position: static; order: -1; }
  body[data-step='0'] .preview, body[data-step='4'] .preview, body[data-step='5'] .preview { order: 1; }
  .preview__canvas { padding: 12px; min-height: 200px; }
  .preview__canvas svg { max-height: 46vh; }
  .panel { gap: 32px; padding-bottom: 24px; }
  .card { padding: 18px; }
  .section__head h2 { font-size: 21px; }
  .pager { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .pager__info { display: none; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-grid--wide { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .topbar__actions .button--ghost { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
