/* ============================================
   NIVEAU 23 — LES VARIABLES CSS
   Styles spécifiques au chapitre
   ============================================ */

/* ---------- DÉMO SCOPING ---------- */
.scope-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.scope-box {
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
  background: #f8fafc;
}

.scope-box .label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}

.scope-root { border-color: #2563eb; background: #eff6ff; }
.scope-child-a { border-color: #7c3aed; background: #f5f3ff; }
.scope-child-b { border-color: #16a34a; background: #f0fdf4; }

/* ---------- DÉMO THEMES ---------- */
.theme-demo {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 1rem;
}

.theme-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--theme-bg, #ffffff);
  border-bottom: 1px solid var(--theme-border, #e2e8f0);
}

.theme-header .title {
  font-weight: 700;
  color: var(--theme-text, #1e293b);
}

.theme-toggle {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--theme-border, #e2e8f0);
  border-radius: 6px;
  background: var(--theme-card-bg, #f8fafc);
  color: var(--theme-text, #1e293b);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: background 0.3s, color 0.3s;
}

.theme-body {
  padding: 1.5rem;
  background: var(--theme-bg, #ffffff);
  color: var(--theme-text, #1e293b);
  transition: background 0.3s, color 0.3s;
}

.theme-card {
  background: var(--theme-card-bg, #f8fafc);
  border: 1px solid var(--theme-border, #e2e8f0);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: background 0.3s, border-color 0.3s;
}

.theme-card:last-child { margin-bottom: 0; }

.theme-card h4 {
  color: var(--theme-text, #1e293b);
  margin-bottom: 0.25rem;
}

.theme-card p {
  color: var(--theme-text-secondary, #64748b);
  font-size: 0.85rem;
  margin: 0;
}

/* Thème clair */
[data-theme="light"] {
  --theme-bg: #ffffff;
  --theme-text: #1e293b;
  --theme-text-secondary: #64748b;
  --theme-card-bg: #f8fafc;
  --theme-border: #e2e8f0;
  --theme-primary: #2563eb;
}

/* Thème sombre */
[data-theme="dark"] {
  --theme-bg: #0f172a;
  --theme-text: #f1f5f9;
  --theme-text-secondary: #94a3b8;
  --theme-card-bg: #1e293b;
  --theme-border: #334155;
  --theme-primary: #60a5fa;
}

/* ---------- DÉMO DESIGN TOKENS ---------- */
.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.token-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.token-swatch {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.token-swatch.light-text { color: white; }
.token-swatch.dark-text { color: #1e293b; }

.token-info {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
}

.token-info .name {
  font-weight: 600;
  color: #1e293b;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}

.token-info .value {
  color: #64748b;
  font-size: 0.75rem;
}

/* ---------- DÉMO TYPOGRAPHY SCALE ---------- */
.type-scale {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.type-scale-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.type-scale-item:last-child { border-bottom: none; }

.type-scale-label {
  width: 120px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  flex-shrink: 0;
}

.type-scale-value {
  color: #1e293b;
  white-space: nowrap;
}

/* ---------- DÉMO SPACING SCALE ---------- */
.spacing-scale {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 1rem;
}

.spacing-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.spacing-box {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 4px;
  width: var(--space, 16px);
  height: var(--space, 16px);
  transition: all 0.3s;
}

.spacing-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}

/* ---------- DÉMO SHADOW SYSTEM ---------- */
.shadow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.shadow-item {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
}

.shadow-item .label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}

/* ---------- DÉMO COMPOSANTS THEMABLES ---------- */
.themed-components {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.themed-btn {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--btn-radius, 6px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary-themed {
  background: var(--btn-primary-bg, #2563eb);
  color: var(--btn-primary-text, white);
}
.btn-primary-themed:hover {
  background: var(--btn-primary-hover, #1d4ed8);
}

.btn-secondary-themed {
  background: var(--btn-secondary-bg, #f1f5f9);
  color: var(--btn-secondary-text, #1e293b);
  border: 1px solid var(--btn-secondary-border, #e2e8f0);
}

.btn-success-themed {
  background: var(--btn-success-bg, #16a34a);
  color: var(--btn-success-text, white);
}

.btn-outline-themed {
  background: transparent;
  color: var(--btn-outline-text, #2563eb);
  border: 2px solid var(--btn-outline-border, #2563eb);
}

/* ---------- DÉMO ARCHITECTURE NOMMAGE ---------- */
.naming-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.naming-category {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem;
}

.naming-category h4 {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: #1e293b;
}

.naming-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.naming-list li {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.8rem;
  padding: 0.25rem 0;
  color: #64748b;
  border-bottom: 1px solid #f1f5f9;
}

.naming-list li:last-child { border-bottom: none; }

.naming-list li span {
  color: #7c3aed;
  font-weight: 600;
}

/* ---------- DÉMO CSS-ONLY THEME TOGGLE ---------- */
.css-toggle-demo {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1rem;
  padding: 1.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.toggle-switch {
  position: relative;
  width: 56px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: "☀";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #1e293b;
}

.toggle-switch input:checked + .toggle-slider::before {
  content: "☾";
  transform: translateX(28px);
}

.toggle-label {
  font-weight: 600;
  color: #1e293b;
}

/* ---------- DÉMO CONTAINER QUERIES ---------- */
.cq-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.cq-card {
  container-type: inline-size;
  background: var(--cq-bg, #f8fafc);
  border: 1px solid var(--cq-border, #e2e8f0);
  border-radius: 8px;
  padding: 1rem;
  overflow: hidden;
}

.cq-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cq-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.cq-card-info h4 {
  font-size: 0.9rem;
  margin-bottom: 0.1rem;
}

.cq-card-info p {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0;
}

.cq-card-body {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: #475569;
}

/* ---------- DÉMO DYNAMIC VALUES ---------- */
.dynamic-demo {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.dynamic-slider-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dynamic-slider-group label {
  width: 120px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
}

.dynamic-slider-group input[type="range"] {
  flex: 1;
  accent-color: #2563eb;
}

.dynamic-slider-group .value {
  width: 50px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: #2563eb;
  font-weight: 600;
}

.dynamic-preview {
  padding: 1.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

.dynamic-preview .preview-box {
  background: var(--dyn-color, #2563eb);
  width: var(--dyn-size, 80px);
  height: var(--dyn-size, 80px);
  border-radius: var(--dyn-radius, 8px);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
}

/* ---------- DÉMO CASCADE LAYERS ---------- */
.layers-demo {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 1rem;
}

.layers-header {
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 700;
  font-size: 0.9rem;
}

.layers-content {
  padding: 1.5rem;
}

.layers-note {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 0.5rem;
  font-style: italic;
}

/* ---------- DÉMO DESIGN SYSTEM ---------- */
.design-system {
  display: grid;
  gap: 2rem;
  margin-top: 1rem;
}

.ds-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
}

.ds-section h4 {
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.ds-color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ds-color-chip {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid rgba(0,0,0,0.05);
}

.ds-space-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ds-space-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.ds-space-block {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 3px;
}

.ds-space-label {
  font-size: 0.65rem;
  color: #64748b;
  font-family: monospace;
}

.ds-type-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ds-type-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.3rem 0;
}

.ds-type-name {
  width: 80px;
  font-size: 0.75rem;
  color: #64748b;
  font-family: monospace;
  flex-shrink: 0;
}

.ds-shadow-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.ds-shadow-item {
  background: white;
  border-radius: 8px;
  padding: 1.5rem 1rem;
  text-align: center;
}

.ds-shadow-item .name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
}

/* ---------- DÉMO PALETTE GENERATOR ---------- */
.palette-demo {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
}

.palette-shade {
  height: 60px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  border: 1px solid rgba(0,0,0,0.05);
}

.palette-shade.light { color: white; }
.palette-shade.dark { color: #1e293b; }
