/* ==========================================================================
   KAGU — components.css
   Composants partagés par design-system.html et index.html.
   Règle : le « plein » est à plat (pas d'ombre), le « creux » est en retrait.
   ========================================================================== */

/* ---- Icônes ---------------------------------------------------------------- */
.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon--fill { fill: currentColor; stroke: none; }

/* ---- Logo ------------------------------------------------------------------ */
.logo { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; color: inherit; border-radius: 10px; }
.logo__mark { width: 2rem; height: 2rem; }
.logo__mark .body { fill: currentColor; }
.logo__mark .piece { fill: var(--vide); transition: transform var(--d-dock) var(--ease-dock); transform-origin: 25px 7px; }
.logo:hover .piece { transform: translate(-1px, 1px) scale(1.08); }
.logo__word { font-family: var(--font-display); font-weight: 800; font-stretch: 75%; font-size: 1.7rem; letter-spacing: -0.02em; line-height: 1; padding-bottom: 0.1em; }

/* ---- Boutons --------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-line: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--hit-lg); padding: 0 var(--s-5);
  border: 1.5px solid var(--btn-line); border-radius: var(--r-s);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 650; font-size: var(--fs-body); line-height: 1; text-decoration: none; white-space: nowrap;
  transition: background-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out),
              border-color var(--d-fast) var(--ease-out), transform var(--d-instant) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn--primary { --btn-bg: var(--ink); --btn-fg: var(--on-ink); --btn-line: var(--ink); }
.btn--primary:hover:not(:disabled) { --btn-bg: var(--ink-3); --btn-line: var(--ink-3); }
.btn--secondary:hover:not(:disabled) { --btn-bg: var(--sunk); --btn-line: var(--ink); }
.btn--ghost { --btn-bg: transparent; --btn-line: transparent; }
.btn--ghost:hover:not(:disabled) { --btn-bg: var(--sunk); }
.btn--sm { min-height: var(--hit); padding: 0 var(--s-4); font-size: var(--fs-small); }
.btn--block { width: 100%; }
/* Variante pour fonds d'encre : on inverse fond ET texte ensemble. */
.on-dark .btn--secondary { --btn-bg: transparent; --btn-fg: var(--on-ink); --btn-line: oklch(1 0 0 / 0.28); }
.on-dark .btn--secondary:hover:not(:disabled) { --btn-bg: oklch(1 0 0 / 0.12); --btn-fg: var(--on-ink); --btn-line: var(--on-ink); }
.on-dark .btn--primary { --btn-bg: var(--on-ink); --btn-fg: var(--ink); --btn-line: var(--on-ink); }
.on-dark .btn--primary:hover:not(:disabled) { --btn-bg: oklch(0.90 0.02 172); --btn-fg: var(--ink); --btn-line: oklch(0.90 0.02 172); }
.on-dark .btn--ghost { --btn-fg: var(--on-ink); }
.on-dark .btn--ghost:hover:not(:disabled) { --btn-bg: oklch(1 0 0 / 0.12); }

.btn-icon {
  display: inline-grid; place-items: center; width: var(--hit); height: var(--hit); flex: none;
  border: 1.5px solid transparent; border-radius: var(--r-pill); background: transparent; color: inherit; padding: 0;
  transition: background-color var(--d-fast) var(--ease-out), transform var(--d-instant) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:hover:not(:disabled) { background: var(--sunk); }
.btn-icon:active:not(:disabled) { transform: scale(0.92); }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }
.on-dark .btn-icon:hover:not(:disabled) { background: oklch(1 0 0 / 0.14); }
.btn-icon--solid { background: var(--ink); color: var(--on-ink); }
.btn-icon--solid:hover:not(:disabled) { background: var(--ink-3); }

/* ---- Étiquettes & badges ----------------------------------------------------- */
.tag {
  display: inline-flex; align-items: center; gap: 0.4em; min-height: 1.75rem; padding: 0 0.7em;
  border-radius: var(--r-pill); border: 1.5px solid var(--line); background: transparent;
  font-family: var(--font-mono); font-size: var(--fs-micro); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
}
.tag--ink { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.tag--soft { background: var(--sunk); border-color: transparent; }
.tag--warn { background: var(--warn); border-color: var(--warn); color: var(--ink); }

/* ---- Chips filtres ------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.5em; min-height: 40px; padding: 0 var(--s-4);
  border-radius: var(--r-pill); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: var(--fs-small); font-weight: 600; white-space: nowrap; line-height: 1;
  transition: background-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out), transform var(--d-instant) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
@media (pointer: coarse) { .chip { min-height: var(--hit); } }
.chip:hover { border-color: var(--ink); background: var(--sunk); }
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip[aria-pressed="true"]:hover, .chip.is-on:hover { background: var(--ink-3); border-color: var(--ink-3); color: var(--on-ink); }
.chip__count { font-family: var(--font-mono); font-size: var(--fs-micro); font-weight: 500; opacity: 0.72; }
.chip--ghost { background: transparent; }

/* ---- Contrôle segmenté ----------------------------------------------------------- */
.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; border-radius: var(--r-s); background: var(--sunk); box-shadow: var(--recess); }
.seg__thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / var(--n, 2)); border-radius: calc(var(--r-s) - 3px); background: var(--ink); transform: translateX(calc(var(--i, 0) * 100%)); transition: transform var(--d-base) var(--ease-dock); }
.seg__opt { position: relative; z-index: 1; display: grid; place-items: center; min-height: 44px; padding: 0 var(--s-3); border: 0; background: transparent; border-radius: calc(var(--r-s) - 3px); font-weight: 650; font-size: var(--fs-small); text-align: center; line-height: 1.15; color: var(--ink); transition: color var(--d-fast) var(--ease-out); }
.seg__opt[aria-checked="true"] { color: var(--on-ink); }
.seg__opt:not([aria-checked="true"]):hover { color: var(--ink-3); }

/* ---- Interrupteur « libre » ----------------------------------------------------- */
.switch {
  display: inline-flex; align-items: center; gap: 0.5em; min-height: 32px; padding: 0 0.15rem 0 0.55rem; border: 0; background: transparent;
  font-family: var(--font-mono); font-size: var(--fs-micro); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.switch__track { position: relative; width: 30px; height: 18px; border-radius: 99px; background: var(--sunk-2); transition: background-color var(--d-fast) var(--ease-out); }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); transition: transform var(--d-base) var(--ease-dock); }
.switch[aria-pressed="true"] { color: var(--ink); }
.switch[aria-pressed="true"] .switch__track { background: var(--ink); }
.switch[aria-pressed="true"] .switch__track::after { transform: translateX(12px); }
.switch:focus-visible { outline-offset: 2px; }

/* ---- Champ de cote ----------------------------------------------------------------- */
.dim {
  container-type: inline-size;
  display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3);
  border-radius: var(--r-m); background: var(--sunk); box-shadow: var(--recess);
  transition: opacity var(--d-base) var(--ease-out);
}
.dim__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-1); }
.dim__label { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.dim__value { display: flex; align-items: baseline; gap: 0.25em; min-width: 0; }
.dim__input {
  width: 100%; min-width: 0; padding: 0; border: 0; border-radius: 6px; background: transparent;
  font-family: var(--font-display); font-weight: 700; font-stretch: 78%; font-size: clamp(1.5rem, calc((100cqw - 34px) / 1.3), var(--fs-num)); line-height: 1.05; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums; color: var(--ink); -moz-appearance: textfield; appearance: textfield;
}
.dim__input::-webkit-outer-spin-button, .dim__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dim__input:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.dim__unit { font-family: var(--font-mono); font-size: var(--fs-small); color: var(--muted); }
.dim__steps { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dim__step {
  display: grid; place-items: center; min-height: var(--hit); border: 0; border-radius: var(--r-xs); background: var(--surface); color: var(--ink);
  transition: background-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out), transform var(--d-instant) var(--ease-out);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
}
.dim__step:hover { background: var(--ink); color: var(--on-ink); }
.dim__step:active { transform: scale(0.94); }
.dim.is-free .dim__input { color: var(--muted); }
.dim.is-free .dim__steps { opacity: 0.4; pointer-events: none; }
.dim.is-free .dim__value { opacity: 0.55; }
.dim.is-bump .dim__input { animation: bump var(--d-base) var(--ease-dock); }
@keyframes bump { 0% { transform: translateY(0); } 35% { transform: translateY(-3px); } 100% { transform: translateY(0); } }

/* ---- Curseur de marge -------------------------------------------------------------- */
.range { display: grid; gap: var(--s-2); }
.range__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.range__out { font-family: var(--font-display); font-weight: 700; font-stretch: 80%; font-size: 1.5rem; font-variant-numeric: tabular-nums; line-height: 1; }
.range__out small { font-family: var(--font-mono); font-size: var(--fs-small); font-weight: 400; color: var(--muted); margin-left: 0.2em; }
.range input[type="range"] {
  --p: 30%; -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; padding: 0; background: transparent; cursor: pointer; touch-action: pan-y;
}
.range input[type="range"]::-webkit-slider-runnable-track { height: 14px; border-radius: 99px; background: linear-gradient(var(--ink), var(--ink)) 0 / var(--p) 100% no-repeat, var(--sunk); box-shadow: var(--recess); }
.range input[type="range"]::-moz-range-track { height: 14px; border-radius: 99px; background: var(--sunk); box-shadow: var(--recess); }
.range input[type="range"]::-moz-range-progress { height: 14px; border-radius: 99px; background: var(--ink); }
.range input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 30px; height: 30px; margin-top: -8px; border-radius: 50%; background: var(--surface); border: 6px solid var(--ink); box-shadow: 0 0 0 3px var(--paper); transition: transform var(--d-fast) var(--ease-dock); }
.range input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 6px solid var(--ink); box-shadow: 0 0 0 3px var(--paper); }
.range input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
.range input[type="range"]:focus-visible { outline: none; }
.range input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.range input[type="range"]:focus-visible::-moz-range-thumb { outline: 3px solid var(--focus-ring); outline-offset: 3px; }

/* ---- Pastille de matière ------------------------------------------------------------- */
.swatch {
  --sw: var(--m-chene); position: relative; display: inline-grid; place-items: center; width: var(--hit); height: var(--hit); padding: 0; border: 0; border-radius: 50%; background: transparent;
  -webkit-tap-highlight-color: transparent;
}
.swatch::before { content: ""; width: 28px; height: 28px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px oklch(0.2 0.04 195 / 0.18); transition: transform var(--d-base) var(--ease-dock); }
.swatch::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; border: 2px solid var(--ink); opacity: 0; transform: scale(0.8); transition: opacity var(--d-fast) var(--ease-out), transform var(--d-base) var(--ease-dock); }
.swatch:hover::before { transform: scale(1.1); }
.swatch[aria-pressed="true"]::after, .swatch[aria-checked="true"]::after { opacity: 1; transform: scale(1); }
.swatch--sm { width: 20px; height: 20px; pointer-events: none; }
.swatch--sm::before { width: 16px; height: 16px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px oklch(0.2 0.04 195 / 0.2); flex: none; }

/* ---- Jauges de jeu ---------------------------------------------------------------------- */
.gauges { display: grid; gap: 6px; }
.gauge { display: grid; grid-template-columns: 1.1rem 1fr auto; align-items: center; gap: var(--s-2); font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.03em; }
.gauge__bar { position: relative; height: 6px; border-radius: 99px; background: var(--sunk-2); overflow: hidden; }
.gauge__bar::after { content: ""; position: absolute; inset: 0; border-radius: 99px; background: var(--ink); transform-origin: left; transform: scaleX(var(--fill, 0)); transition: transform var(--d-slow) var(--ease-out); }
.gauge__val { min-width: 3.4em; text-align: right; font-weight: 500; }
.gauge.is-free { opacity: 0.45; }

/* ---- Carte produit à encoche : le geste signature ------------------------------------ */
.card {
  --behind: var(--paper);
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border-radius: var(--r-l);
  text-align: left; isolation: isolate;
}
.card__cut { position: absolute; top: 0; right: 0; z-index: 2; width: var(--notch); height: var(--notch); background: var(--behind); border-bottom-left-radius: var(--notch-r); pointer-events: none; }
.card__cut::before, .card__cut::after {
  content: ""; position: absolute; width: var(--notch-r); height: var(--notch-r);
  background: radial-gradient(circle at 0 100%, transparent calc(var(--notch-r) - 0.5px), var(--behind) var(--notch-r));
}
.card__cut::before { right: 100%; top: 0; }
.card__cut::after  { right: 0; top: 100%; }
.card__fav { position: absolute; top: 6px; right: 6px; z-index: 3; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: var(--ink); color: var(--on-ink); transition: background-color var(--d-fast) var(--ease-out), transform var(--d-dock) var(--ease-dock); -webkit-tap-highlight-color: transparent; }
.card__fav:hover { background: var(--ink-3); }
.card__fav:active { transform: scale(0.88); }
.card__fav[aria-pressed="true"] { background: var(--on-ink); color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.card__fav[aria-pressed="true"] .icon { fill: currentColor; }
.card__fav.is-pop { animation: pop var(--d-dock) var(--ease-dock); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

.plate { position: relative; display: grid; place-items: stretch; aspect-ratio: 4 / 3; padding: 11% 10% 15%; border-radius: var(--r-l); background: var(--sunk); overflow: hidden; }
.plate svg.art { width: 100%; height: 100%; max-width: none; position: relative; z-index: 1; }
.plate::after { content: ""; position: absolute; left: 10%; right: 10%; bottom: 12%; height: 6%; border-radius: 50%; background: radial-gradient(closest-side, oklch(0.25 0.05 195 / 0.22), transparent); }

/* ---- Pastille de niche (aperçu du meuble dans le vide) ---------------------------- */
.mini-niche { position: relative; border-radius: var(--r-s); background: var(--ink-deep); box-shadow: var(--recess-dark); overflow: hidden; }

/* ---- Feuille / dialogue ----------------------------------------------------------------- */
.sheet { padding: 0; border: 0; background: var(--paper); color: var(--ink); overscroll-behavior: contain; }
.sheet::backdrop { background: oklch(0.2 0.045 195 / 0); backdrop-filter: blur(0); transition: background-color var(--d-base) var(--ease-out), backdrop-filter var(--d-base) var(--ease-out); }
.sheet.is-open::backdrop { background: oklch(0.2 0.045 195 / 0.55); backdrop-filter: blur(3px); }
.sheet__panel { transition: transform var(--d-slow) var(--ease-out), opacity var(--d-base) var(--ease-out); }

/* ---- Toast ---------------------------------------------------------------------------------- */
.toast-zone { position: fixed; left: 0; right: 0; bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 100; display: grid; justify-items: center; gap: var(--s-2); pointer-events: none; padding: 0 var(--s-4); }
.toast { display: inline-flex; align-items: center; gap: var(--s-3); max-width: 28rem; padding: var(--s-3) var(--s-4); border-radius: var(--r-s); background: var(--ink); color: var(--on-ink); font-size: var(--fs-small); font-weight: 600; box-shadow: var(--lift); animation: toast-in var(--d-slow) var(--ease-dock) both; }
.toast.is-out { animation: toast-out var(--d-base) var(--ease-out) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---- État vide ------------------------------------------------------------------------------- */
.empty { display: grid; justify-items: center; gap: var(--s-4); padding: var(--s-7) var(--s-5); border-radius: var(--r-l); background: var(--sunk); box-shadow: var(--recess); text-align: center; }
.empty__title { max-width: 22ch; }
.empty__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; }

/* ---- Squelette ---------------------------------------------------------------------------------- */
.skel { background: linear-gradient(100deg, var(--sunk) 30%, var(--sunk-2) 50%, var(--sunk) 70%) 0 / 300% 100%; border-radius: var(--r-s); animation: skel 1.4s linear infinite; }
@keyframes skel { to { background-position: -300% 0; } }

/* ---- Pastilles d'étape ------------------------------------------------------------------------ */
.steps { display: flex; align-items: center; gap: var(--s-2); font-family: var(--font-mono); font-size: var(--fs-micro); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.steps__item { display: inline-flex; align-items: center; gap: 0.5em; }
.steps__pip { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid currentColor; font-size: 0.7rem; transition: background-color var(--d-base) var(--ease-out), color var(--d-base) var(--ease-out); }
.steps__item.is-on { color: var(--ink); }
.steps__item.is-on .steps__pip, .steps__item.is-done .steps__pip { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.steps__item.is-done { color: var(--ink); }
.steps__bar { flex: 1; height: 2px; min-width: 12px; max-width: 48px; background: var(--line); }

@media (hover: none) { .btn--primary:hover:not(:disabled) { --btn-bg: var(--ink); --btn-line: var(--ink); } }

.sheet__panel:focus { outline: none; }

.steps { flex-wrap: wrap; row-gap: var(--s-1); }
@media (max-width: 400px) { .steps { gap: 6px; } .steps__bar { max-width: 12px; min-width: 6px; } }

/* Zones tactiles : 44 px minimum, sans agrandir le dessin. */
.logo { min-height: var(--hit); }
.dim__step { position: relative; }
.dim__step::after { content: ""; position: absolute; inset: 0 -3px; }
.switch { position: relative; }
.switch::before { content: ""; position: absolute; inset: -7px -4px; }
.dim__value { min-height: var(--hit); align-items: center; cursor: text; }
@media (max-width: 1023px) { .chip { min-height: var(--hit); } }
