@import url("token.css");

/* ============================================================
   Reset global + base
   ============================================================ */
*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--cib-font-sans);
  color: var(--cib-ink);
  background: var(--cib-surface);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ============================================================
   App shell : éditeur (aside) + canvas (zone de travail)
   ============================================================ */
.app {
  display: flex;
  height: 100%;
  width: 100%;
}

/* Zone de travail à droite : prend tout l'espace restant */
.canvas {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: var(--cib-space-48);
  background: #fafafa;
  overflow: auto;
}

/* Colonne empilée Preview + Export ; margin auto la centre sans rogner en haut quand ça déborde */
.work {
  margin: auto;
  width: 560px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--cib-space-24);
}

/* ============================================================
   cib-editor — coquille
   ============================================================ */
.editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 20rem;
  background: var(--cib-surface);
  border-right: 1px solid var(--cib-border);
}
.editor__head { flex: 0 0 auto; padding: var(--cib-space-12) var(--cib-space-24); border-bottom: 1px solid var(--cib-border); display: flex; flex-direction: column; gap: var(--cib-space-12); }
.editor__title { margin: 0; display: flex; align-items: baseline; gap: var(--cib-space-8); font-size: var(--cib-text-sm); font-weight: var(--cib-font-regular); }
.editor__title b { font-weight: var(--cib-font-semibold); }
.editor__title span { font-size: var(--cib-text-xs); color: var(--cib-text-muted); }

.editor__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--cib-space-16) var(--cib-space-24);
  display: flex;
  flex-direction: column;
  gap: var(--cib-space-24);
}

.editor__section { display: flex; flex-direction: column; gap: var(--cib-space-12); }
.editor__section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--cib-space-12); }
.editor__label {
  margin: 0;
  font-size: var(--cib-text-xs);
  font-weight: var(--cib-font-semibold);
  letter-spacing: var(--cib-tracking-wide);
  text-transform: uppercase;
  color: var(--cib-text-faint);
}

.editor__actions { display: flex; flex-direction: column; gap: var(--cib-space-12); margin-top: var(--cib-space-4); }
.editor__actions-row { display: flex; gap: var(--cib-space-12); }
.editor__actions-row > .btn { flex: 1; }

.editor__foot {
  flex: 0 0 auto;
  padding: var(--cib-space-12) var(--cib-space-24);
  border-top: 1px solid var(--cib-border);
  display: flex;
  flex-direction: column;
  gap: var(--cib-space-12);
}
.editor__credit {
  margin: 0;
  width: 0;
  min-width: 100%;
  font-size: var(--cib-text-xs);
  line-height: var(--cib-leading-relaxed);
  color: var(--cib-text-muted);
}
.editor__credit b { font-weight: var(--cib-font-semibold); color: var(--cib-ink); }
.editor__toggles { display: flex; gap: var(--cib-space-20); }

/* Dérogation éditeur : actions denses → 14px (cib-editor) */
.editor .btn.cta,
.editor .btn.btn-secondary { font-size: var(--cib-text-sm); }

/* ============================================================
   cib-controls — tabs, slider, color
   ============================================================ */
.tabs {
  display: flex;
  padding: var(--cib-space-4);
  background: var(--cib-surface-sunken);
  border-radius: var(--cib-radius-md);
}
.tabs__item {
  flex: 1;
  padding: var(--cib-space-8) var(--cib-space-12);
  font-family: inherit;
  font-size: var(--cib-text-xs);
  font-weight: var(--cib-font-medium);
  color: var(--cib-text-muted);
  background: 0 0;
  border: none;
  border-radius: var(--cib-radius-sm);
  cursor: pointer;
  transition:
    background-color var(--cib-duration-fast) var(--cib-ease),
    color var(--cib-duration-fast) var(--cib-ease);
}
.tabs__item:hover:not(.tabs__item--active),
.tabs__item--hover:not(.tabs__item--active) { color: var(--cib-ink); }
.tabs__item--active {
  background-color: var(--cib-surface);
  color: var(--cib-ink);
  box-shadow: var(--cib-shadow-raised);
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--cib-text-xs);
  color: var(--cib-text-control);
  margin-bottom: var(--cib-space-6);
}
.field-value {
  font-variant-numeric: tabular-nums;
  font-family: var(--cib-font-mono);
  font-size: var(--cib-text-xs);
  color: var(--cib-ink);
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: transparent;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--cib-track); border-radius: var(--cib-radius-2xs); }
input[type="range"]::-moz-range-track { height: 3px; background: var(--cib-track); border-radius: var(--cib-radius-2xs); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  margin-top: -5.5px;
  border: none; border-radius: 50%;
  background: var(--cib-ink); cursor: pointer;
  transition: transform var(--cib-duration-fast) var(--cib-ease), box-shadow var(--cib-duration-fast) var(--cib-ease);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border: none; border-radius: 50%;
  background: var(--cib-ink); cursor: pointer;
  transition: transform var(--cib-duration-fast) var(--cib-ease), box-shadow var(--cib-duration-fast) var(--cib-ease);
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.1); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: var(--cib-shadow-focus); }
input[type="range"]:hover::-moz-range-thumb { transform: scale(1.1); }
input[type="range"]:active::-moz-range-thumb { transform: scale(1.15); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: var(--cib-shadow-focus); }

.color-field { display: flex; justify-content: space-between; align-items: center; }
.color-field .field-label { font-size: var(--cib-text-xs); color: var(--cib-text-control); }
input[type="color"] {
  width: 38px;
  height: 28px;
  border: 1px solid var(--cib-border);
  border-radius: var(--cib-radius-sm);
  background: var(--cib-surface);
  padding: var(--cib-space-2);
  cursor: pointer;
  transition: border-color var(--cib-duration-fast) var(--cib-ease);
}
input[type="color"]:hover { border-color: var(--cib-gray-300); }
input[type="color"]:focus-visible { outline: var(--cib-focus-outline); outline-offset: var(--cib-focus-offset); }
input[type="color"]:disabled { opacity: .3; cursor: not-allowed; }

/* ============================================================
   cib-input — input, select, checkbox, switch, file-upload
   ============================================================ */
.input {
  width: 100%;
  padding: var(--cib-space-8) var(--cib-space-12);
  border: 1px solid var(--cib-border);
  border-radius: var(--cib-radius-md);
  background-color: var(--cib-surface);
  color: var(--cib-ink);
  font-family: var(--cib-font-sans);
  font-size: var(--cib-text-sm);
  transition: border-color var(--cib-duration-fast) var(--cib-ease);
  line-height: var(--cib-leading-normal);
}
.input:focus { border-color: var(--cib-ink); outline: none; }
.input:disabled { background-color: var(--cib-surface-muted); color: var(--cib-text-muted); cursor: not-allowed; }

select {
  width: 100%;
  background: var(--cib-surface);
  color: var(--cib-ink);
  border: 1px solid var(--cib-border);
  border-radius: var(--cib-radius-md);
  padding: var(--cib-space-8) var(--cib-space-32) var(--cib-space-8) var(--cib-space-12);
  font-family: inherit;
  font-size: var(--cib-text-sm);
  outline: none;
  cursor: pointer;
  transition: border-color var(--cib-duration), box-shadow var(--cib-duration);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
select:focus { border-color: var(--cib-ink); box-shadow: var(--cib-shadow-focus); }
select:disabled { background-color: var(--cib-surface-muted); color: var(--cib-text-muted); cursor: not-allowed; }

.checkbox { accent-color: var(--cib-ink); cursor: pointer; }
.checkbox:disabled { cursor: not-allowed; }

.switch { position: relative; display: inline-flex; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.slider {
  width: 24px;
  height: 14px;
  background: var(--cib-switch-off);
  border-radius: var(--cib-radius-full);
  position: relative;
  transition: background var(--cib-duration-slow);
  flex-shrink: 0;
  box-shadow: var(--cib-shadow-switch-track);
}
.slider::after {
  content: '';
  position: absolute;
  top: var(--cib-space-2);
  left: var(--cib-space-2);
  width: 10px;
  height: 10px;
  background: var(--cib-white);
  border-radius: 50%;
  transition: left var(--cib-duration-slow), background var(--cib-duration-slow);
  box-shadow: var(--cib-shadow-switch-thumb);
}
.switch input:checked + .slider { background: var(--cib-ink); }
.switch input:checked + .slider::after { left: 12px; }
.switch input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }

.file-upload {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--cib-space-8);
  width: 100%;
  margin-top: var(--cib-space-8);
  padding: var(--cib-space-8) var(--cib-space-12);
  background: var(--cib-surface);
  border: 1px dashed var(--cib-border);
  border-radius: var(--cib-radius-md);
  cursor: pointer;
  font-size: var(--cib-text-xs);
  color: var(--cib-text-muted);
  user-select: none;
  transition: border-color var(--cib-duration), color var(--cib-duration), background var(--cib-duration);
}
.file-upload:hover { border-color: var(--cib-gray-900); color: var(--cib-ink); }
.file-upload:has(input:disabled) {
  background-color: var(--cib-surface-muted);
  border-color: var(--cib-border);
  color: var(--cib-text-muted);
  cursor: not-allowed;
}

.check { display: inline-flex; align-items: center; gap: var(--cib-space-8); font-size: var(--cib-text-xs); color: var(--cib-ink); cursor: pointer; }
.check:active { transform: translateY(0.5px); }
.check:has(.switch input:not(:checked)) { color: var(--cib-text-muted); }
.check:has(.checkbox:disabled),
.check:has(.switch input:disabled) { color: var(--cib-text-muted); cursor: not-allowed; }

/* ============================================================
   cib-button
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  line-height: var(--cib-leading-tight);
  transition:
    background-image var(--cib-duration-fast) var(--cib-ease-default),
    background-color var(--cib-duration) var(--cib-ease-default),
    box-shadow var(--cib-duration-fast) var(--cib-ease-default),
    transform var(--cib-duration-instant) var(--cib-ease-default);
}
.btn:disabled,
.btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }
.btn:focus-visible,
.btn[aria-current="page"],
.btn[aria-current="true"] { outline: var(--cib-focus-outline); outline-offset: var(--cib-focus-offset); }
.btn .icon { width: 16px; height: 16px; flex: 0 0 auto; display: block; }

.cta {
  gap: var(--cib-space-16);
  padding: var(--cib-space-8) var(--cib-space-16);
  border-radius: var(--cib-radius-md);
  color: var(--cib-ink);
  font-size: var(--cib-text-base);
  font-weight: var(--cib-font-medium);
  background-color: var(--cib-accent);
  background-image: linear-gradient(var(--cib-accent-top), var(--cib-accent));
  box-shadow: var(--cib-shadow-cta);
  text-shadow: 0 1px #fff3, 1px 1px 6px #fff;
}
.cta .icon { width: 18px; height: 18px; }
.cta:hover {
  background-image: linear-gradient(var(--cib-accent-top-hover), var(--cib-accent));
  box-shadow: var(--cib-shadow-cta-hover);
}
.cta:active {
  text-shadow: 0 -1px #fff6;
  background-image: linear-gradient(var(--cib-accent-top-active), var(--cib-accent));
  box-shadow: var(--cib-shadow-cta-active);
}

.btn-secondary {
  gap: var(--cib-space-8);
  padding: var(--cib-space-8) var(--cib-space-12);
  font-size: var(--cib-text-base);
  font-weight: var(--cib-font-medium);
  border-radius: var(--cib-radius-md);
  color: var(--cib-ink);
  background: var(--cib-surface);
}
.btn-secondary:hover { box-shadow: var(--cib-shadow-ring-hover); }

.btn-tiertary {
  gap: var(--cib-space-6);
  padding: var(--cib-space-2) var(--cib-space-8);
  font-size: var(--cib-text-xs);
  font-weight: var(--cib-font-medium);
  border-radius: var(--cib-radius-xs);
  color: var(--cib-text-control);
  background: none;
}
.btn-tiertary .icon { width: 14px; height: 14px; }
.btn-tiertary:hover { background: var(--cib-surface-sunken); color: var(--cib-ink); }

.btn-secondary,
.btn-tiertary { box-shadow: var(--cib-shadow-ring); }
.btn-secondary:active,
.btn-tiertary:active { transform: translateY(0.5px); }

.text-link {
  color: var(--cib-ink);
  font-size: var(--cib-text-xs);
  font-weight: var(--cib-font-medium);
  text-decoration: none;
}
.text-link:hover { text-decoration: underline; }
.text-link:focus-visible {
  outline: var(--cib-focus-outline);
  outline-offset: var(--cib-focus-offset);
  border-radius: var(--cib-radius-2xs);
}

/* ============================================================
   cib-marker — pill, divider
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--cib-space-4);
  padding: var(--cib-space-4) var(--cib-space-12);
  border-radius: var(--cib-radius-full);
  background-color: var(--cib-ink);
  color: var(--cib-white);
  font-family: inherit;
  font-size: var(--cib-text-xs);
  font-weight: var(--cib-font-semibold);
  line-height: var(--cib-leading-snug);
}
.pill--light {
  background-color: var(--cib-surface-muted);
  color: var(--cib-text-control);
  font-weight: var(--cib-font-medium);
  border: 1px solid var(--cib-border);
}
.divider { width: 100%; height: 1px; background-color: var(--cib-border); }

/* ============================================================
   cib-signature
   ============================================================ */
.signature {
  display: inline-block;
  line-height: 0;
  border-radius: var(--cib-radius-2xs);
  transition: opacity var(--cib-duration) var(--cib-ease);
}
.signature:hover { opacity: .7; }
.signature:focus-visible { outline: var(--cib-focus-outline); outline-offset: var(--cib-focus-offset); }
.signature__mark { display: block; width: 64px; height: auto; }
.signature--canvas {
  position: absolute;
  right: var(--cib-space-24);
  bottom: var(--cib-space-24);
  z-index: 1;
}

/* ============================================================
   Outil-spécifique : cartes, preview, faux onglet, picker, snippet
   ============================================================ */

/* --- Carte (cib-card : conteneur Preview / Export) --- */
.card {
  background: var(--cib-surface);
  border: 1px solid var(--cib-border);
  border-radius: var(--cib-radius-md);
  box-shadow: var(--cib-shadow-raised);
  overflow: hidden;
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--cib-space-12);
  padding: var(--cib-space-12) var(--cib-space-16);
  border-bottom: 1px solid var(--cib-border);
}
.card__label {
  font-size: var(--cib-text-xs);
  font-weight: var(--cib-font-semibold);
  letter-spacing: var(--cib-tracking-wide);
  text-transform: uppercase;
  color: var(--cib-text-faint);
}
.card__body { padding: var(--cib-space-24) var(--cib-space-16); display: flex; flex-direction: column; gap: var(--cib-space-16); }
.card__hint {
  font-size: var(--cib-text-xs);
  line-height: var(--cib-leading-relaxed);
  color: var(--cib-text-muted);
}
.card__hint code {
  font-family: var(--cib-font-mono);
  font-size: 0.92em;
  padding: 0 var(--cib-space-4);
  border-radius: var(--cib-radius-2xs);
  background: var(--cib-surface-sunken);
  color: var(--cib-ink);
}

/* --- Faux onglet navigateur (preview live) --- */
.preview { align-items: center; gap: var(--cib-space-24); }

/* --- Aperçus aux tailles réelles 16 / 32 sur damier transparence --- */
.sizes { display: flex; gap: var(--cib-space-32); align-items: flex-end; }
.size { display: flex; flex-direction: column; align-items: center; gap: var(--cib-space-8); margin: 0; }
.size__stage {
  display: grid;
  place-items: center;
  padding: var(--cib-space-12);
  border-radius: var(--cib-radius-sm);
  border: 1px solid var(--cib-border);
  background:
    repeating-conic-gradient(var(--cib-gray-200) 0 25%, transparent 0 50%)
      0 0 / 12px 12px,
    var(--cib-white);
}
.size__img { display: block; image-rendering: -webkit-optimize-contrast; }
.size__cap {
  font-size: var(--cib-text-xs);
  font-variant-numeric: tabular-nums;
  font-family: var(--cib-font-mono);
  color: var(--cib-text-muted);
}

.browser {
  width: 100%;
  border-radius: var(--cib-radius-md) var(--cib-radius-md) var(--cib-radius-sm) var(--cib-radius-sm);
  overflow: hidden;
  box-shadow: var(--cib-shadow-raised), 0 12px 40px rgba(10, 10, 10, 0.12);
  background: var(--cib-surface);
  border: 1px solid var(--cib-border);
}
.browser--dark { background: #1c1c1e; border-color: #000; }

.browser__chrome {
  display: flex;
  align-items: flex-end;
  gap: var(--cib-space-8);
  padding: var(--cib-space-8) var(--cib-space-12) 0;
  background: var(--cib-surface-sunken);
}
.browser--dark .browser__chrome { background: #2c2c2e; }

.browser__dots { display: flex; gap: 6px; padding-bottom: var(--cib-space-8); }
.browser__dots span { width: 11px; height: 11px; border-radius: 50%; background: var(--cib-gray-300); }
.browser--dark .browser__dots span { background: #48484a; }

.browser__tab {
  display: flex;
  align-items: center;
  gap: var(--cib-space-8);
  max-width: 200px;
  padding: var(--cib-space-8) var(--cib-space-12);
  background: var(--cib-surface);
  border-radius: var(--cib-radius-sm) var(--cib-radius-sm) 0 0;
  font-size: var(--cib-text-xs);
  color: var(--cib-ink);
}
.browser--dark .browser__tab { background: #1c1c1e; color: var(--cib-dark-text); }
.browser__favicon { width: 16px; height: 16px; flex: 0 0 auto; image-rendering: -webkit-optimize-contrast; }
.browser__tabtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.browser__close { margin-left: auto; color: var(--cib-text-muted); font-size: 14px; line-height: 1; }

.browser__body {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--cib-space-12);
  padding: var(--cib-space-24);
  color: var(--cib-text-faint);
}
.browser--dark .browser__body { color: #636366; }
.browser__bigfavicon {
  width: 64px;
  height: 64px;
  border-radius: var(--cib-radius-sm);
  image-rendering: -webkit-optimize-contrast;
}

.preview__hint { font-size: var(--cib-text-xs); color: var(--cib-text-muted); text-align: center; max-width: 360px; }

/* --- Picker de presets (vignettes hover-anim, propre à l'outil) --- */
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: var(--cib-space-12); }
.preset {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--cib-space-8);
  padding: var(--cib-space-16) var(--cib-space-12) var(--cib-space-12);
  background: var(--cib-surface);
  border: 1px solid var(--cib-border);
  border-radius: var(--cib-radius-md);
  cursor: pointer;
  transition: border-color var(--cib-duration) var(--cib-ease), box-shadow var(--cib-duration) var(--cib-ease);
}
.preset:hover { border-color: var(--cib-gray-300); box-shadow: var(--cib-shadow-ring-hover); }
.preset[aria-pressed="true"] { border-color: var(--cib-ink); box-shadow: var(--cib-shadow-ring); }
.preset[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 2px solid var(--cib-ink);
  border-radius: var(--cib-radius-md);
  pointer-events: none;
}
.preset__thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--cib-radius-sm);
  background: var(--cib-surface-sunken);
}
.preset__label {
  font-size: var(--cib-text-xs);
  font-weight: var(--cib-font-medium);
  color: var(--cib-text-control);
}

/* --- Champ select avec libellé --- */
.field { display: flex; flex-direction: column; }
.field-label { font-size: var(--cib-text-xs); color: var(--cib-text-control); margin-bottom: var(--cib-space-6); }

/* --- Sortie snippet --- */
.snippet {
  position: relative;
  border-radius: var(--cib-radius-sm);
  background: var(--cib-ink);
  overflow: hidden;
}
.snippet pre {
  margin: 0;
  padding: var(--cib-space-12);
  height: 180px;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: var(--cib-font-mono);
  font-size: var(--cib-text-xs);
  line-height: var(--cib-leading-relaxed);
  color: #e5e5e5;
  white-space: pre-wrap;
  word-break: break-all;
  tab-size: 2;
}

/* Petit état "copié" sur le CTA */
.cta.is-copied { filter: saturate(1.1); }
