/* ═══════════════════════════════════════════════════════════
   CEJILLA — Diseño CDI-ITCR  (versión corregida)
   ═══════════════════════════════════════════════════════════ */

:root {
  --cj-navy:   #1a2e4a;
  --cj-teal:   #2a7f7f;
  --cj-gold:   #c8922a;
  --cj-cream:  #f8f4ed;
  --cj-cream2: #ede8df;
  --cj-cream3: #e4ddd3;
  --cj-text:   #2c2c2c;
  --cj-muted:  #6b6b6b;
  --cj-r:      10px;
}

/* ══════════════════════════════════════════════════════════
   1. CEJILLA
   ══════════════════════════════════════════════════════════ */

.cejilla-wrapper {
  border-radius: var(--cj-r);
  overflow: hidden;
  box-shadow: 0 2px 14px rgba(26,46,74,.09);
  background: white;
  margin: 1rem 0;
  border-left: 4px solid var(--cj-gold);
}

/* ── Botón ── */
.cejilla-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .95rem 1.2rem;
  background: white;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: 'Playfair Display', 'PT Serif', serif;
  font-size: 1.02rem;
  color: var(--cj-navy);
  line-height: 1.3;
  transition: background .2s, color .2s;
}

.cejilla-toggle:hover {
  background: var(--cj-cream);
}

.cejilla-toggle[aria-expanded="true"] {
  background: var(--cj-navy);
  color: var(--cj-cream);
}

/* ── Ícono ── */
.cejilla-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--cj-cream2);
  color: var(--cj-navy);
  transition: transform .32s ease;
}

.cejilla-toggle[aria-expanded="true"] .cejilla-icon {
  background: var(--cj-gold);
  color: white;
  transform: rotate(180deg);
}

/* ── CONTENIDO (CORREGIDO) ── */
.cejilla-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height .4s cubic-bezier(.4,0,.2,1);
  border-top: 1px solid var(--cj-cream2);
  padding: 0;
}

/* mantener animación */
.cejilla-content[hidden] {
  display: block !important;
  max-height: 0 !important;
  visibility: hidden;
}

.cejilla-content.open {
  max-height: 4000px;
  visibility: visible;
  padding: 1.2rem 1.4rem 1.4rem;
}

/* 🔧 CLAVE: eliminar padding repetido */
.cejilla-content > * {
  padding: 0 !important;
}

/* controlar párrafos */
.cejilla-content p {
  margin-top: 0.35em;
  margin-bottom: 0.35em;
  line-height: 1.45;
}

.cejilla-content p:first-child {
  margin-top: 0;
}

.cejilla-content p:last-child {
  margin-bottom: 0;
}

/* evitar márgenes colapsados de make4ht */
.cejilla-content > *:first-child {
  margin-top: 0 !important;
}

.cejilla-content > *:last-child {
  margin-bottom: 0 !important;
}

/* ══════════════════════════════════════════════════════════
   2. HEJERSOL
   ══════════════════════════════════════════════════════════ */

.ejercicio-solucion {
  margin: .8rem 0 1.2rem 0;
}

.solucion-container {
  display: flex;
  flex-direction: column;
}

/* botón */
.solucion-container > button {
  align-self: flex-start;
  padding: .38rem 1rem;
  background: var(--cj-teal);
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: .82rem;
}

.solucion {
  overflow: hidden;
  max-height: 0;
  visibility: hidden;
  transition: max-height .38s;
}

.solucion.sol-visible {
  max-height: 3000px;
  visibility: visible;
  margin-top: .65rem;
}

.solucion > * {
  background: var(--cj-cream);
  border-left: 4px solid var(--cj-teal);
  padding: .9rem 1.1rem;
}

/* ══════════════════════════════════════════════════════════
   3. BTN-TUTOR
   ══════════════════════════════════════════════════════════ */

.btn-tutor {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .42rem 1.1rem;
  background: var(--cj-navy);
  color: var(--cj-cream);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: .82rem;
  box-shadow: 0 2px 8px rgba(26,46,74,.18);
}

.btn-tutor:hover {
  background: var(--cj-teal);
}

/* ══════════════════════════════════════════════════════════
   4. GCEJILLA  (ventana grande, borde #029185, anidable)
   ══════════════════════════════════════════════════════════ */

.gcejilla-wrapper {
  border-radius: 8px;
  overflow: hidden;
  background: white;
  margin: 1.2rem 0;
  border: 1.5px solid #ffc523;
}

/* ── Botón ── */
.gcejilla-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .95rem 1.2rem;
  background: white;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background .2s, color .2s;
}

.gcejilla-toggle:hover {
  background: #fff8e1;
}

.gcejilla-toggle[aria-expanded="true"] {
  background: #029185;
}

/* ── Texto del título ── */
.gcejilla-label {
  color: #6e6943 !important;
  font-weight: bold;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  font-size: 1.3em;
  font-family: 'Playfair Display', 'PT Serif', serif;
  line-height: 1.3;
}

.gcejilla-toggle[aria-expanded="true"] .gcejilla-label {
  color: white !important;
}

/* ── Disco con flecha gruesa ── */
.gcejilla-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ffc523;
  display: grid;
  place-items: center;
  transition: transform .32s ease;
}

/* Chevron grueso (border trick) apuntando ↓ */
.gcejilla-icon::after {
  content: '';
  display: block;
  width: 11px;
  height: 11px;
  border-right: 3.5px solid white;
  border-bottom: 3.5px solid white;
  transform: rotate(45deg) translate(-2px, -2px);
}

/* Al abrir: disco gira 180° → flecha apunta ↑ */
.gcejilla-toggle[aria-expanded="true"] .gcejilla-icon {
  background: white;
  transform: rotate(180deg);
}

.gcejilla-toggle[aria-expanded="true"] .gcejilla-icon::after {
  border-color: #ffc523;
}

/* ── Contenido ── */
.gcejilla-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height .42s cubic-bezier(.4,0,.2,1);
  border-top: 1.5px solid #ffc523;
  padding: 0;
}

.gcejilla-content[hidden] {
  display: block !important;
  max-height: 0 !important;
  visibility: hidden;
}

.gcejilla-content.open {
  max-height: 12000px;   /* grande: puede anidar cejillamk */
  visibility: visible;
  padding: 1.4rem 1.6rem 1.6rem;
}

.gcejilla-content > *:first-child { margin-top: 0 !important; }
.gcejilla-content > *:last-child  { margin-bottom: 0 !important; }
