/* ==========================================================================
   TENON · Atelier de meubles sur mesure — jetons et composants partagés
   Bois, lin et une touche de laiton. Cormorant pour les titres, Inter Tight pour
   l'interface, JetBrains Mono pour toutes les cotes, codes de pièces et montants en colonne.
   ========================================================================== */

:root {
  --linen: #f3eee6;
  --paper: #fbf8f3;
  --sand: #e7dfd2;
  --sand-2: #dcd2c2;
  --ink: #231c16;
  --ink-2: #3a3029;
  --walnut: #5a3f2c;
  --walnut-bg: #2a2019;
  --oak: #c79e6f;
  --brass: #b0873a;
  --brass-2: #c9a25a;
  --brass-ink: #7a5a1e;
  --brass-soft: rgba(176, 135, 58, .14);
  --ok: #4f7a57;
  --warn: #c98a2b;
  --red: #b4442f;
  --muted: #6f6257;
  --rule: rgba(35, 28, 22, .12);
  --rule-2: rgba(35, 28, 22, .2);
  --shadow: 0 1px 0 rgba(35, 28, 22, .04), 0 18px 40px -26px rgba(35, 28, 22, .35);
  --shadow-lg: 0 30px 80px -30px rgba(35, 28, 22, .45);
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --r: 14px;
  --r-lg: 22px;
  --hd: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--hd) + 12px); }
body { margin: 0; background: var(--linen); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-feature-settings: "ss01"; }
img, svg { display: block; max-width: 100%; }
svg use { pointer-events: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: var(--mono); font-feature-settings: "zero" 0; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 760px) { .wrap { padding: 0 32px; } }

/* ---------- Titres ---------- */
.h-serif { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; line-height: 1.02; }
/* Cormorant dessine des chiffres elzéviriens : dans les titres, cotes et montants, chiffres alignés */
.h-serif, .sheet__head h2, [class*="__t"], .plan h3, .mat h3, .pbar__amt { font-variant-numeric: lining-nums; }
.h-serif em { font-style: italic; }
.kicker { display: inline-flex; align-items: center; gap: 10px; font: 500 11px/1.3 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--brass-ink); }
.kicker::before { content: ""; width: 18px; height: 1px; background: currentColor; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo svg { width: 30px; height: 30px; }
.logo__w { display: grid; line-height: 1; }
.logo__name { font-family: var(--serif); font-size: 22px; letter-spacing: .18em; padding-left: .18em; margin-left: -.18em; }
.logo__tag { margin-top: 3px; font: 500 9.5px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-variant: small-caps; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 999px; font-weight: 600; font-size: 15px; letter-spacing: -.005em; text-decoration: none; white-space: nowrap; transition: transform .25s var(--ease), background-color .2s, box-shadow .2s, color .2s; }
.btn:active { transform: scale(.97); }
.btn--brass { background: var(--brass); color: var(--ink); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12); }
.btn--brass:hover { background: var(--brass-2); }
.btn--ink { background: var(--ink); color: var(--paper); }
.btn--ghost { box-shadow: inset 0 0 0 1px var(--rule-2); color: var(--ink); background: transparent; }
.btn--ghost:hover { box-shadow: inset 0 0 0 1px var(--ink); }
.btn--sm { min-height: 44px; padding: 0 16px; font-size: 14px; }
.btn--icon { width: 48px; padding: 0; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.link { color: var(--brass-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* ---------- Segments (onglets compacts) ---------- */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--sand); }
.seg button, .seg a { min-height: 38px; padding: 0 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; transition: background-color .2s, color .2s, box-shadow .2s; }
.seg [aria-selected="true"], .seg [aria-pressed="true"], .seg [aria-current="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(35, 28, 22, .12); }
.seg--sm button { min-height: 32px; padding: 0 11px; font-size: 12.5px; }
/* petits segments : la zone touchable fait quand même 44 px de haut */
.seg--sm button { position: relative; }
.seg--sm button::after { content: ""; position: absolute; inset: -6px 0; }
.seg--block { display: flex; }
.seg--block > * { flex: 1; }

/* ---------- Puces ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px 16px; margin: 0 -16px; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--rule); font-size: 14.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; scroll-snap-align: start; transition: box-shadow .2s, background-color .2s; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); box-shadow: none; }
.chip svg { width: 18px; height: 18px; }

/* ---------- Champs ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, .select { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--rule-2); background: var(--paper); font-size: 16px; outline: none; transition: border-color .2s, box-shadow .2s; }
.input:focus, .select:focus { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

/* ---------- Feuille (bottom sheet), ouverte seulement par un geste du visiteur ---------- */
.sheet { position: fixed; inset: 0; z-index: 90; visibility: hidden; overflow: hidden; pointer-events: none; }
.sheet.is-open { visibility: visible; pointer-events: auto; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(35, 28, 22, .38); opacity: 0; transition: opacity .3s; }
.sheet.is-open .sheet__scrim { opacity: 1; }
.sheet__panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column; border-radius: 22px 22px 0 0; background: var(--paper); box-shadow: var(--shadow-lg); transform: translateY(102%); transition: transform .45s var(--ease); }
.sheet.is-open .sheet__panel { transform: none; }
.sheet__grip { width: 40px; height: 4px; margin: 10px auto 2px; border-radius: 4px; background: var(--sand-2); flex: none; }
.sheet__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 20px 8px; flex: none; }
.sheet__head h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.05; letter-spacing: -.01em; }
.sheet__close { width: 44px; height: 44px; margin: -6px -10px 0 0; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px calc(20px + var(--safe-b)); }
@media (min-width: 900px) {
  .sheet__panel { left: auto; top: 0; right: 0; bottom: 0; width: 480px; max-height: none; border-radius: 0; transform: translateX(102%); }
  .sheet__grip { display: none; }
  .sheet__head { padding-top: 26px; }
}

/* ---------- Toasts (opaques) ---------- */
.toasts { position: fixed; z-index: 85; left: 50%; top: calc(var(--hd) + 10px); transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow-lg); font-size: 14px; line-height: 1.35; pointer-events: auto; animation: toast-in .45s var(--ease); }
.toast b { font-weight: 600; }
.toast .ico { color: var(--brass-2); }
.toast.is-out { opacity: 0; transform: translateY(-8px); transition: opacity .3s, transform .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- Barre « Projet concept » ---------- */
.demo-bar { position: relative; z-index: 60; display: flex; align-items: center; justify-content: space-between; gap: 4px 16px; min-height: 34px; padding: 7px 16px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); background: #1b1511; color: rgba(243, 238, 230, .66); font: 12.5px/1.35 var(--sans); }
.demo-bar b { color: #fff; font-weight: 600; }
.demo-bar a { padding: 12px 0; margin: -12px 0; color: #ff8a63; text-underline-offset: 3px; }
.demo-bar > span:first-child { flex: 1; min-width: 0; }
.demo-bar__links { display: flex; flex-wrap: wrap; gap: 2px 16px; }
.demo-bar__short { display: none; }
@media (max-width: 960px) {
  .demo-bar { flex-wrap: nowrap; white-space: nowrap; }
  .demo-bar > span:first-child { overflow: hidden; text-overflow: ellipsis; }
  .demo-bar__long { display: none; }
  .demo-bar__short { display: inline; }
  .demo-bar__links { flex-wrap: nowrap; }
}
.is-embed .demo-bar { display: none !important; }

/* ---------- Étiquettes ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font: 500 11.5px/1.4 var(--mono); letter-spacing: .02em; background: var(--sand); color: var(--ink-2); white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.tag--ok { background: rgba(79, 122, 87, .14); color: #3c6144; }
.tag--warn { background: rgba(201, 138, 43, .16); color: #8a5c14; }
.tag--red { background: rgba(180, 68, 47, .13); color: var(--red); }
.tag--brass { background: var(--brass-soft); color: var(--brass-ink); }

/* ---------- Vue du meuble (composant view.js) ---------- */
.fv { position: relative; overflow: hidden; background: var(--linen); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.fv__gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .5s; }
.fv[data-mode="3d"] .fv__gl { opacity: 1; }
.fv__plan { position: absolute; inset: 0; display: none; }
.fv[data-mode="plan"] .fv__plan { display: block; }
.fv__plan svg { width: 100%; height: 100%; }
.fv__plan [data-col] { cursor: pointer; }
.fv__cotes { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.fv__line { fill: none; stroke: var(--brass); stroke-width: 1.5; stroke-linecap: round; }
.fv__ext { fill: none; stroke: var(--brass); stroke-width: .9; opacity: .65; }
.fv__knob { position: absolute; left: 0; top: 0; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; touch-action: none; cursor: grab; display: grid; place-items: center; z-index: 3; outline: none; }
.fv__knob i { width: 14px; height: 14px; border-radius: 50%; background: var(--brass); box-shadow: 0 0 0 4px rgba(251, 248, 243, .92), 0 0 0 5px rgba(176, 135, 58, .55), 0 4px 10px rgba(35, 28, 22, .25); transition: transform .2s var(--ease); }
.fv__knob::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; border: 1.5px solid var(--brass); opacity: 0; animation: knob-pulse 2.6s var(--ease) infinite; }
.fv__knob[data-cote="h"]::after { animation-delay: 1.3s; }
.fv__knob:hover i, .fv__knob.is-active i, .fv__knob:focus-visible i { transform: scale(1.25); }
.fv.is-dragging .fv__knob::after, .fv.was-touched .fv__knob::after { animation: none; }
.fv.is-dragging { cursor: grabbing; }
@keyframes knob-pulse { 0% { transform: scale(.5); opacity: .9; } 70%, 100% { transform: scale(1.35); opacity: 0; } }
.fv__fig { position: absolute; left: 0; top: 0; z-index: 2; min-height: 30px; padding: 4px 9px; border-radius: 8px; font: 500 13px/1 var(--mono); letter-spacing: -.02em; color: var(--brass-ink); background: rgba(243, 238, 230, .92); box-shadow: inset 0 0 0 1px rgba(176, 135, 58, .35); white-space: nowrap; }
.fv__fig::before { content: ""; position: absolute; inset: -8px -4px; }
.fv__fig--h { transform-origin: 50% 50%; }
.fv__input { position: absolute; left: 0; top: 0; z-index: 4; width: 92px; height: 36px; padding: 0 8px; border-radius: 8px; border: 1.5px solid var(--brass); background: var(--paper); font: 500 16px/1 var(--mono); text-align: center; color: var(--ink); outline: none; box-shadow: 0 6px 18px rgba(35, 28, 22, .2); }
.fv__seg { position: absolute; z-index: 3; top: 10px; left: 10px; background: rgba(231, 223, 210, .9); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.fv.no-webgl .fv__seg { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Cibles tactiles : au moins 44 px sans changer le dessin */
.seg--sm button[data-cur] { min-width: 40px; }
button.link, a.link { position: relative; }
button.link::after, a.link::after { content: ""; position: absolute; inset: -12px -4px; }
