/**
 * CodePen Block Styles - Grade A V5
 * Composant code interactif avec onglets HTML/CSS et iFrame CodePen
 * 
 * @version 2.0.0
 * @author Frédéric Moitry - Formation Product Designer UX/UI
 * 
 * Changelog V5 (v2.0.0):
 * - Hauteur adaptative avec max-height 350px
 * - Scroll vertical automatique si le code dépasse
 */

/* ============================================
   CONTENEUR PRINCIPAL
   ============================================ */
.codepen-block {
  margin: 20px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ============================================
   LABEL "Code à implémenter"
   ============================================ */
.codepen-block-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
}

/* ============================================
   EN-TÊTE : ONGLETS + BOUTON COPIER
   ============================================ */
.codepen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

/* Groupe d'onglets toggle */
.codepen-tabs {
  display: flex;
  gap: 0;
}

.codepen-tab {
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #666;
  color: #fff;
}

.codepen-tab:first-child {
  border-radius: 4px 0 0 4px;
}

.codepen-tab:last-child {
  border-radius: 0 4px 4px 0;
}

.codepen-tab:not(.active) {
  background: #e0e0e0;
  color: #333;
}

.codepen-tab:hover:not(.active) {
  background: #ccc;
}

.codepen-tab.active {
  background: #666;
  color: #fff;
}

/* Bouton Copier */
.codepen-copy-btn {
  padding: 6px 16px;
  font-size: 13px;
  color: #0066cc;
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s ease;
}

.codepen-copy-btn:hover {
  color: #004499;
}

.codepen-copy-btn.copied {
  color: #28a745;
  text-decoration: none;
}

/* ============================================
   ZONE DE CODE
   V5: Hauteur adaptative avec scroll vertical
   ============================================ */
.codepen-code-container {
  position: relative;
}

.codepen-code {
  display: none;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-left: 4px solid #999;
  padding: 15px 20px;
  margin: 0;
  font-family: "Fira Code", "Consolas", "Monaco", monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  overflow-y: auto;
  white-space: pre;
  color: #333;
  border-radius: 0 0 4px 4px;
  /* V5: Hauteur adaptative min 200px, max 350px */
  min-height: 100px;
  max-height: 350px;
}

.codepen-code.active {
  display: block;
}

/* Syntax highlighting basique */
.codepen-code .tag {
  color: #e91e63;
}

.codepen-code .attr {
  color: #ff9800;
}

.codepen-code .value {
  color: #4caf50;
}

.codepen-code .property {
  color: #2196f3;
}

.codepen-code .selector {
  color: #9c27b0;
}

.codepen-code .comment {
  color: #9e9e9e;
  font-style: italic;
}

/* ============================================
   IFRAME CODEPEN - VERSION MINIMALISTE
   ============================================ */
.codepen-embed {
  margin-top: 15px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.codepen-embed iframe {
  display: block;
  width: 100%;
  height: 400px;
  border: none;
  background: #1e1e1e;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 576px) {
  .codepen-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .codepen-tab {
    padding: 6px 14px;
    font-size: 13px;
  }

  .codepen-code {
    font-size: 12px;
    padding: 12px 15px;
  }

  .codepen-embed iframe {
    height: 350px;
  }
}

/* ============================================
   INTÉGRATION DANS ACCORDÉON WPA
   ============================================ */
.wpa-accordion-content .codepen-block {
  margin: 15px 0;
}

.wpa-accordion-content .codepen-block:first-child {
  margin-top: 0;
}

.wpa-accordion-content .codepen-block:last-child {
  margin-bottom: 0;
}

/* ============================================
   SECTION OBJECTIF (TUTO)
   ============================================ */
.tuto-objectif {
  background: #fff;
  border-left: 4px solid #667eea;
  padding: 20px 24px;
  margin-bottom: 24px;
  border-radius: 0 8px 8px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tuto-objectif h3 {
  font-size: 16px;
  color: #667eea;
  margin: 0 0 8px 0;
  font-weight: 600;
}

.tuto-objectif p {
  color: #555;
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
}

.tuto-objectif code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  color: #c7254e;
}

/* ============================================
   NUMÉRO ACCORDÉON (TUTO)
   ============================================ */
.wpa-accordion-number {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  margin-right: 12px;
  font-weight: 600;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .codepen-embed {
    display: none;
  }

  .codepen-copy-btn {
    display: none;
  }

  .codepen-code {
    display: block !important;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .codepen-tabs {
    display: none;
  }
}
