/* Ejercicios de código dentro de la lección (codelab.js) */

.cl-runner { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }
.cl-slot { margin: 1.25rem 0; }
.cl-loading { display: flex; align-items: center; gap: .5rem; color: var(--ink-3); font-size: .9rem; padding: 1rem; border: 1.5px dashed var(--line); border-radius: 14px; }
.cl-loading .lp-ico, .cl .lp-ico { width: 16px; height: 16px; }

.cl {
  margin: 1.5rem 0; border: 1.5px solid var(--line); border-radius: 16px; background: var(--card);
  overflow: hidden; box-shadow: var(--shadow); min-width: 0;
}
.cl.is-ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.cl-head { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.cl-lang {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  color: var(--brand); background: var(--brand-50); border-radius: 999px; padding: .25rem .6rem;
}
.cl-title { flex: 1; min-width: 0; font-size: .95rem; }
.cl-state { font-size: .74rem; font-weight: 700; color: #92400e; background: #fff7e6; border-radius: 999px; padding: .25rem .6rem; }
.cl.is-ok .cl-state { color: #047857; background: var(--ok-50); }

.cl-ed { font-size: 14px; }
.cl-ed .cm-editor { min-height: 140px; max-height: 60vh; }
.cl-ed .cm-editor.cm-focused { outline: none; box-shadow: inset 0 0 0 2px var(--brand); }
.cl-ed .cm-scroller { font-family: ui-monospace, 'Cascadia Code', Consolas, 'Courier New', monospace; line-height: 1.6; font-variant-ligatures: none; }

.cl-in { border-top: 1px solid var(--line); padding: .5rem 1rem; font-size: .85rem; }
.cl-in summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }
.cl-in textarea {
  width: 100%; margin-top: .4rem; font: 13px/1.5 ui-monospace, Consolas, monospace; border: 1.5px solid var(--line);
  border-radius: 10px; padding: .5rem .6rem; background: var(--bg); color: var(--ink); resize: vertical;
}

.cl-bar { display: flex; align-items: center; gap: .5rem; padding: .65rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.cl-bar .btn { display: inline-flex; align-items: center; gap: .35rem; }
.cl-bar .btn-ok { background: var(--ok); color: #fff; }
.cl-bar .btn-ok:hover { filter: brightness(.95); }
.cl-bar .btn:disabled { opacity: .6; cursor: wait; }
.cl-kbd { margin-left: auto; color: var(--ink-3); font-size: .75rem; }

.cl-out { border-top: 1px solid var(--line); }
.cl-out[hidden] { display: none; }
.cl-preview { position: relative; }
.cl-preview.is-loading::after {
  content: attr(data-msg); position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, #fff 85%, transparent); color: #475569; font-size: .9rem; font-weight: 600;
}
.cl-preview iframe { display: block; width: 100%; height: 340px; border: 0; background: #fff; resize: vertical; }
.cl-console {
  background: #0f172a; color: #e2e8f0; font: 13px/1.55 ui-monospace, 'Cascadia Code', Consolas, 'Courier New', monospace; font-variant-ligatures: none;
  padding: .75rem 1rem; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.cl-console:empty { display: none; }
.cl-line.err { color: #fca5a5; }
.cl-line.status { color: #94a3b8; font-style: italic; }
.cl-img { display: block; max-width: 100%; height: auto; margin: .5rem 0; border-radius: 8px; background: #fff; }
.cl-table { overflow-x: auto; margin: .35rem 0 .6rem; }
.cl-table table { border-collapse: collapse; font-size: 12.5px; min-width: 100%; }
.cl-table th, .cl-table td { border: 1px solid #334155; padding: .3rem .55rem; text-align: left; white-space: nowrap; }
.cl-table th { background: #1e293b; color: #f8fafc; }
.cl-table small { color: #94a3b8; }

.cl-tests { list-style: none; margin: 0; padding: .75rem 1rem; display: grid; gap: .4rem; background: var(--card); }
.cl-tests[hidden] { display: none; }
.cl-tests li { display: grid; gap: .1rem; font-size: .88rem; }
.cl-tests li.ok b { color: #047857; }
.cl-tests li.bad b { color: #b91c1c; }
.cl-tests li span { color: var(--ink-2); font-size: .82rem; padding-left: 1.2rem; }
.cl-tests li.cl-sum { font-weight: 800; padding: .45rem .7rem; border-radius: 10px; }
.cl-tests li.cl-sum.ok { background: var(--ok-50); color: #047857; }
.cl-tests li.cl-sum.bad { background: #fff7e6; color: #92400e; }
.cl-need { font-size: .85rem; }

@media (max-width: 640px) {
  .cl { border-radius: 14px; margin-left: -4px; margin-right: -4px; }
  .cl-head, .cl-bar { padding-left: .75rem; padding-right: .75rem; }
  .cl-kbd { display: none; }
  .cl-bar { flex-wrap: nowrap; gap: .4rem; }
  .cl-bar .btn { flex: 1 1 0; min-width: 0; justify-content: center; padding-left: .5rem; padding-right: .5rem; white-space: nowrap; }
  .cl-bar [data-reset] span { display: none; }
  .cl-bar [data-reset] { flex: 0 0 44px; }
  .cl-ed .cm-editor { min-height: 96px; }
  .cl-preview iframe { height: 280px; }
}

html[data-theme="dark"] .cl-state { background: rgba(245, 158, 11, .15); color: #fcd34d; }
html[data-theme="dark"] .cl.is-ok .cl-state { color: #6ee7b7; }
html[data-theme="dark"] .cl-tests li.ok b, html[data-theme="dark"] .cl-tests li.cl-sum.ok { color: #6ee7b7; }
html[data-theme="dark"] .cl-tests li.bad b { color: #fca5a5; }
html[data-theme="dark"] .cl-tests li.cl-sum.bad { background: rgba(245, 158, 11, .14); color: #fcd34d; }
