/* ==========================================================================
   MYRIAGE — Illustrations des pages de piste
   01 · Table de montage   02 · Câbles qui se rangent   03 · Pile d'un outil
   Comportements dans assets/js/illustrations.js. Tout est décoratif : chaque
   illustration porte un aria-label, et le texte de la page dit la même chose.
   ========================================================================== */

.tool-panel {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vw, 14px);
  padding: clamp(8px, 1.2vw, 16px);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  background: var(--c-surface);
}
.tool-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 6px 2px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--c-text-muted);
}
.tool-panel__head > span { display: flex; align-items: center; gap: 10px; }
.tool-box {
  border: 1px solid var(--c-line);
  border-radius: 8px;
  background: var(--c-bg);
}
.fig-caption {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* ==========================================================================
   01 · Table de montage
   ========================================================================== */
.edit__row { display: flex; flex-wrap: wrap; gap: clamp(8px, 1.2vw, 14px); }

.edit__rushes {
  flex: 1 1 240px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}
.edit__rushes-head { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 11px; color: var(--c-text-muted); }
.edit__rushes-head span:first-child { color: var(--c-text); }
.edit__bins { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.edit__bin { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.edit__bin-thumb {
  aspect-ratio: 16 / 9;
  border-radius: var(--r-sm);
  background: repeating-linear-gradient(135deg, #25211A 0 7px, #2E291F 7px 14px);
}
.edit__bin-name {
  overflow: hidden;
  font-family: var(--f-mono);
  font-size: 9.5px;
  color: var(--c-text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.edit__bin--active .edit__bin-thumb { box-shadow: inset 0 0 0 1.5px var(--c-accent); }
.edit__bin--active .edit__bin-name  { color: var(--c-accent); }

@media (max-width: 759px) { .edit__rushes { display: none; } }

.edit__monitor { flex: 3 1 460px; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.edit__screen {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  text-align: center;
  background: repeating-linear-gradient(135deg, #25211A 0 12px, #2C271E 12px 24px);
}
.edit__screen::after {                 /* le moniteur « s'allume » au survol */
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(220, 194, 106, .1);
  box-shadow: inset 0 0 80px rgba(220, 194, 106, .32);
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
}
.edit__screen:hover::after { opacity: 1; animation: flicker .8s linear both; }
.edit__screen-note { font-family: var(--f-mono); font-size: 12px; color: var(--c-text-muted); }
.edit__corner {
  position: absolute;
  top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--c-text-muted);
}
.edit__corner--left  { left: 14px; }
.edit__corner--right { right: 14px; }
.edit__corner .rec__light { width: 6px; height: 6px; }
.edit__subtitle {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 9%;
  font-weight: 600;
  font-size: clamp(12px, 1.3vw, 17px);
  color: var(--c-text);
  text-shadow: 0 1px 2px #000;
}

.edit__controls { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 14px; }
.edit__progress { position: relative; height: 3px; border-radius: 2px; background: var(--c-line); }
.edit__progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--play, .41) * 100%);
  border-radius: 2px;
  background: var(--c-accent);
}
.edit__progress-knob {
  position: absolute;
  top: 50%;
  left: calc(var(--play, .41) * 100%);
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--c-accent);
  transform: translate(-50%, -50%);
}
.edit__transport { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.edit__tc { font-family: var(--f-mono); font-size: 11px; color: var(--c-text); font-variant-numeric: tabular-nums; }
.edit__tc span { color: var(--c-line-strong); }
.edit__buttons { display: flex; gap: 6px; }
.edit__buttons span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--c-line);
  border-radius: 50%;
  font-size: 10px;
  color: var(--c-text-muted);
}
.edit__buttons span:nth-child(2) { border-color: var(--c-accent); background: var(--c-accent); font-size: 11px; color: var(--c-on-accent); }
.edit__ratio {
  padding: 3px 7px;
  border: 1px solid var(--c-line-strong);
  border-radius: 3px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--c-text);
}

/* Timeline : 4 pistes, des clips posés en %, une tête de lecture */
.edit__timeline { padding: 12px 14px 16px; overflow-x: auto; }
.edit__tracks { position: relative; min-width: 620px; display: flex; flex-direction: column; gap: 6px; }
.edit__line {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.edit__line--ruler { align-items: end; }
.edit__line-name { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.edit__line-name b { font-family: var(--f-mono); font-size: 10.5px; font-weight: 400; color: var(--c-text); }
.edit__line-name span { font-size: 11px; color: var(--c-text-muted); }
.edit__ruler {
  display: flex;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--c-line);
  font-family: var(--f-mono);
  font-size: 9.5px;
  color: var(--c-line-strong);
}
.edit__lane { position: relative; height: 34px; border-radius: var(--r-sm); background: var(--c-surface); }
.edit__clip {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: calc(var(--l) * 1%);
  width: calc(var(--w) * 1%);
  display: flex;
  align-items: center;
  padding: 0 8px;
  overflow: hidden;
  border: 1.5px solid var(--track);
  border-radius: var(--r-sm);
  background: color-mix(in oklch, var(--track) 16%, transparent);
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--track);
  white-space: nowrap;
  transition: filter .2s;
}
.edit__clip:hover { filter: brightness(1.45); }
.edit__clip--wave {
  background:
    repeating-linear-gradient(90deg, color-mix(in oklch, var(--track) 45%, transparent) 0 1px, transparent 1px 3px),
    color-mix(in oklch, var(--track) 12%, transparent);
}
.edit__playhead {
  position: absolute;
  top: 0;
  bottom: -4px;
  left: calc(94px + (100% - 94px) * var(--play, .41));
  width: 2px;
  background: var(--c-accent);
  pointer-events: none;
}
.edit__playhead::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--c-accent);
  transform: translateX(-50%) rotate(45deg);
}

/* ==========================================================================
   02 · Les câbles se rangent
   Chaque étiquette porte ses positions « désordre » et « rangé » en
   variables CSS (générées dans le markup) ; .is-tidy bascule de l'un à
   l'autre. Trois mises en page : bureau, deux rangées, colonne mobile.
   ========================================================================== */
.flow-toggle {
  display: flex;
  padding: 3px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  background: var(--c-bg);
}
.flow-toggle button {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-text-muted);
  font-family: var(--f-main);   /* l'en-tête du panneau est en mono */
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.flow-toggle button:first-child[aria-pressed="true"] { background: var(--c-text); color: var(--c-on-accent); }
.flow-toggle button:last-child[aria-pressed="true"]  { background: var(--c-accent); color: var(--c-on-accent); }

.flow {
  position: relative;
  aspect-ratio: 16 / 7;
  overflow: hidden;
}
.flow__cable,
.flow__chip {
  position: absolute;
  transition:
    left .95s var(--ease-zoom) var(--d, 0s),
    top .95s var(--ease-zoom) var(--d, 0s),
    width .95s var(--ease-zoom) var(--d, 0s),
    transform .95s var(--ease-zoom) var(--d, 0s),
    opacity .45s ease var(--d, 0s),
    background-color .6s ease var(--d, 0s);
}

.flow__cable {
  left: calc(var(--cx) * 1%);
  top: calc(var(--cy) * 1%);
  width: calc(var(--cw) * 1%);
  height: 2px;
  border-radius: 2px;
  background: var(--c-line-strong);
  transform: translate(-50%, -50%) rotate(calc(var(--cr) * 1deg));
}

/* Deux délais par étiquette, posés en style inline : --du quand on dérange,
   --dt quand on range. Le choix se fait ici, dans la feuille : si le markup
   posait directement --d en inline, il écraserait la règle de l'état rangé. */
.flow__chip { --d: var(--du, 0s); }
.flow.is-tidy .flow__chip { --d: var(--dt, 0s); }

.flow__chip {
  left: calc(var(--mx) * 1%);
  top: calc(var(--my) * 1%);
  transform: translate(-50%, -50%) rotate(calc(var(--mr) * 1deg));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1.5px solid var(--chip, var(--c-line-strong));
  border-radius: var(--r-sm);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: clamp(11px, 1vw, 13px);
  font-weight: 600;
  white-space: nowrap;
}
.flow__tag { font-family: var(--f-mono); font-size: 10px; font-weight: 500; color: var(--tag, var(--c-accent)); }
.flow__tag:empty { display: none; }
.flow__order { display: none; }

.flow__chip--manual { --chip: var(--c-error); --tag: var(--c-error-text); border-style: dashed; color: var(--c-error-text); }
.flow__chip--ai     { --chip: var(--c-auto);  --tag: var(--c-auto); }
.flow__chip--human  { --chip: var(--c-accent); }

.flow__caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--c-text-muted);
}
.flow__caption-after { display: none; }

/* --- État rangé : bureau (une ligne) --- */
.flow.is-tidy .flow__chip {
  left: calc(var(--tx) * 1%);
  top: calc(var(--ty) * 1%);
  transform: translate(-50%, -50%);
}
.flow.is-tidy .flow__chip--manual {
  left: calc(var(--mx) * 1%);
  top: calc(var(--my) * 1%);
  opacity: 0;
  transform: translate(-50%, -50%) rotate(calc(var(--mr) * 1deg)) scale(.7);
}
.flow.is-tidy .flow__order { display: inline; }
.flow.is-tidy .flow__cable {
  left: 50%;
  top: 50%;
  width: 86%;
  transform: translate(-50%, -50%);
  background: rgba(220, 194, 106, .55);
}
.flow.is-tidy .flow__caption-before { display: none; }
.flow.is-tidy .flow__caption-after  { display: inline; }

/* --- Deux rangées (tablette) --- */
@media (min-width: 760px) and (max-width: 1179px) {
  .flow.is-tidy .flow__chip { left: calc(var(--t2x) * 1%); top: calc(var(--t2y) * 1%); }
  .flow.is-tidy .flow__cable { top: calc(var(--c2y) * 1%); width: calc(var(--c2w) * 1%); }
}

/* --- Colonne (mobile) --- */
@media (max-width: 759px) {
  .flow { aspect-ratio: 3 / 4; }
  .flow__cable {
    left: calc(var(--cmx) * 1%);
    top: calc(var(--cmy) * 1%);
    width: calc(var(--cmw) * 1%);
    transform: translate(-50%, -50%) rotate(calc(var(--cmr) * 1deg));
  }
  .flow__chip { left: calc(var(--mmx) * 1%); top: calc(var(--mmy) * 1%); }
  .flow.is-tidy .flow__chip { left: 50%; top: calc(var(--tmy) * 1%); }
  .flow.is-tidy .flow__chip--manual { left: calc(var(--mmx) * 1%); top: calc(var(--mmy) * 1%); }
  .flow.is-tidy .flow__cable { left: 50%; top: 50%; width: 118%; transform: translate(-50%, -50%) rotate(90deg); }
}

/* ==========================================================================
   03 · La pile d'un outil (3D CSS)
   ========================================================================== */
.stack {
  display: flex;
  flex-direction: row;          /* .tool-panel l'avait mis en colonne */
  flex-wrap: wrap;
  align-items: center;
  gap: 24px clamp(24px, 4vw, 64px);
  padding: clamp(16px, 3vw, 40px);
}
.stack__stage {
  flex: 3 1 420px;
  min-width: 0;
  height: 500px;
  display: grid;
  place-items: center;
  overflow: hidden;
  perspective: 1400px;
  --gap: 0px;
}
.stack.is-in   .stack__stage { --gap: 32px; }
.stack.is-open .stack__stage { --gap: 70px; }

.stack__plate {
  position: relative;
  width: 340px;
  height: 240px;
  margin-top: 70px;
  transform-style: preserve-3d;
  transform: rotateX(56deg) rotateZ(-38deg);
}
.stack__layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px;
  border: 1.5px solid var(--c-line-strong);
  border-radius: 8px;
  background: var(--c-surface);
  box-shadow: 0 28px 36px -22px rgba(0, 0, 0, .6);
  transform: translateZ(calc(var(--i) * var(--gap)));
  transition: transform .7s var(--ease-zoom), border-color .25s, background-color .25s;
}
.stack__layer-name { margin-bottom: 4px; font-family: var(--f-mono); font-size: 10px; color: var(--c-text-muted); }
.stack__bar { display: block; height: var(--h); width: var(--w); border-radius: 2px; background: var(--c, var(--c-line)); }

/* La couche Interface, au sommet : teintée accent, elle s'allume une fois dépliée */
.stack__layer--top { border-color: var(--c-accent); background: var(--c-raised); }
.stack__layer--top .stack__layer-name { color: var(--c-accent); }
.stack__layer--top::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 7px;
  background: rgba(220, 194, 106, .08);
  box-shadow: inset 0 0 36px rgba(220, 194, 106, .32);
  pointer-events: none;
  opacity: 0;
}
.stack.is-open .stack__layer--top::after { opacity: 1; animation: flicker .8s linear both; }

/* Couche mise en avant depuis la légende */
.stack__layer.is-hi {
  border-color: var(--c-saas);
  background: color-mix(in oklch, var(--c-saas) 18%, var(--c-surface));
  transform: translateZ(calc(var(--i) * var(--gap) + 26px));
}
.stack__layer.is-hi .stack__layer-name { color: var(--c-saas); }

.stack__legend { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.stack__list { border-bottom: 1px solid var(--c-line); }
.stack__item {
  width: 100%;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  padding: 16px 0;
  border: 0;
  border-top: 1px solid var(--c-line);
  background: transparent;
  color: var(--c-text);
  text-align: left;
  transition: color .2s;
}
.stack__item.is-hi { color: var(--c-saas); }
.stack__item > span:first-child { padding-top: 5px; font-family: var(--f-mono); font-size: 11px; }
.stack__item strong { display: block; font-weight: 800; font-size: 18px; line-height: 1; text-transform: uppercase; }
.stack__item small { display: block; margin-top: 4px; font-size: 14px; color: var(--c-text-muted); }

@media (max-width: 759px) {
  .stack__stage { height: 320px; }
  .stack.is-in   .stack__stage { --gap: 22px; }
  .stack.is-open .stack__stage { --gap: 46px; }
  .stack__plate { width: 210px; height: 150px; margin-top: 40px; }
}

/* Sans JavaScript : la pile est présentée dépliée */
html:not(.js) .stack__stage { --gap: 32px; }

@media (prefers-reduced-motion: reduce) {
  .flow__cable, .flow__chip, .stack__layer { transition: none !important; }
}
