/* ============================================
   NIVEAU 26 — LE CSS MODERNE
   Styles spécifiques au chapitre
   ============================================ */

/* ---------- DEMO SECTION ---------- */
.demo-box {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1rem;
  background: #f8fafc;
}

.demo-box__title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

/* ---------- CSS NESTING DEMO ---------- */
.nesting-demo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .nesting-demo { grid-template-columns: 1fr; }
}

.nesting-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.5rem;
}

.nesting-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: #2563eb;
}

.nesting-card h4 {
  margin-top: 0;
  color: #1e293b;
}

.nesting-card p {
  color: #64748b;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ---------- @LAYER DEMO ---------- */
.layer-demo {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.layer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.layer-base { background: #eff6ff; border-left: 4px solid #2563eb; }
.layer-component { background: #f0fdf4; border-left: 4px solid #16a34a; }
.layer-utility { background: #faf5ff; border-left: 4px solid #7c3aed; }

/* ---------- CONTAINER QUERY DEMO ---------- */
.cq-parent {
  resize: horizontal;
  overflow: auto;
  border: 2px dashed #d1d5db;
  border-radius: 10px;
  padding: 1rem;
  min-width: 200px;
  max-width: 100%;
  container-type: inline-size;
  container-name: card-container;
}

.cq-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cq-card__img {
  height: 120px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.cq-card__body { padding: 1rem; }
.cq-card__title { font-weight: 700; margin-bottom: 0.25rem; }
.cq-card__text { color: #64748b; font-size: 0.85rem; margin-bottom: 0.75rem; }

@container card-container (min-width: 400px) {
  .cq-card {
    flex-direction: row;
  }
  .cq-card__img {
    width: 180px;
    height: auto;
    min-height: 120px;
  }
  .cq-card__body { padding: 1.25rem; }
}

/* ---------- :HAS() DEMO ---------- */
.has-demo-form {
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.has-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.has-input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

.has-input-group input {
  padding: 0.55rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.has-input-group input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* :has() — parent style when child is focused */
.has-input-group:has(input:focus) {
  background: #eff6ff;
  padding: 0.5rem;
  margin: -0.5rem;
  border-radius: 10px;
}

.has-input-group:has(input:placeholder-shown) label {
  color: #64748b;
}

.has-input-group:has(input:not(:placeholder-shown)) label {
  color: #2563eb;
}

/* :has() — card with image */
.has-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

.has-card:not(:has(.has-card__img)) {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
}

.has-card__img {
  height: 100px;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  width: 100%;
}

.has-card__body { padding: 1rem; }

/* ---------- SCROLL SNAP DEMO ---------- */
.snap-container {
  display: flex;
  overflow-x: auto;
  gap: 1rem;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 1rem 0;
  -webkit-overflow-scrolling: touch;
}

.snap-container::-webkit-scrollbar {
  height: 6px;
}

.snap-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.snap-item {
  flex: 0 0 250px;
  scroll-snap-align: start;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.5rem;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.snap-item__icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.snap-item__title {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.snap-item__text {
  color: #64748b;
  font-size: 0.85rem;
}

/* ---------- COLOR FUNCTIONS DEMO ---------- */
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.color-chip {
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
}

.color-chip__name {
  font-weight: 400;
  opacity: 0.8;
  font-size: 0.7rem;
}

/* ---------- POPOVER API DEMO ---------- */
.popover-trigger {
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
}

.popover-content {
  padding: 1rem;
  min-width: 200px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: white;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

/* ---------- @STARTING-STYLE DEMO ---------- */
.starting-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.starting-item {
  padding: 0.75rem 1rem;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  transition: opacity 0.3s, transform 0.3s;
}

@starting-style {
  .starting-item {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ---------- BROWSER SUPPORT TABLE ---------- */
.support-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.support-table th {
  background: #f1f5f9;
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 2px solid #e2e8f0;
  font-weight: 600;
}

.support-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.support-table .yes { color: #16a34a; font-weight: 600; }
.support-table .no { color: #dc2626; }
.support-table .partial { color: #f59e0b; }
.support-table .flag { font-size: 0.75rem; color: #64748b; }

/* ---------- BEFORE/AFTER REFACTOR ---------- */
.refactor-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .refactor-compare { grid-template-columns: 1fr; }
}

.refactor-before, .refactor-after {
  border-radius: 10px;
  overflow: hidden;
}

.refactor-label {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.refactor-before .refactor-label { background: #fef2f2; color: #991b1b; }
.refactor-after .refactor-label { background: #f0fdf4; color: #166534; }

.refactor-code {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  font-size: 0.8rem;
  font-family: 'Cascadia Code', monospace;
  overflow-x: auto;
  line-height: 1.6;
}
