/* ================================================
   SESION 03 - estilos
================================================ */

/* ---- Search bar animation (Introducción) ---- */
.search-anim-figure {
  margin: 1.5rem 0 0.5rem;
}

.search-anim-scene {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 2.5rem 2rem 0;
  background: linear-gradient(160deg, #eef2ff 0%, #f8fbff 100%);
  border-radius: 20px;
  overflow: hidden;
}

.search-anim-bar {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 520px;
  height: 64px;
  background: white;
  border: 2px solid rgba(100, 149, 237, 0.35);
  border-radius: 999px;
  padding: 0 1.4rem 0 0.55rem;
  gap: 0.8rem;
  box-shadow: 0 6px 24px rgba(100, 149, 237, 0.14), 0 2px 8px rgba(100, 149, 237, 0.08);
  position: relative;
  z-index: 1;
}

.search-anim-icon {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  background: rgba(100, 149, 237, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-anim-icon svg {
  width: 24px;
  height: 24px;
}

.search-anim-input {
  flex: 1;
  display: flex;
  align-items: center;
  font-size: 1.1rem;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.search-caret {
  display: inline-block;
  width: 2px;
  height: 1.15em;
  background: #6495ED;
  margin-left: 1px;
  vertical-align: middle;
  border-radius: 1px;
  animation: search-blink 0.75s step-end infinite;
}

@keyframes search-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.search-hand {
  position: absolute;
  bottom: 0;
  left: calc(50% - 200px);
  transform: translateY(150px);
  opacity: 0;
  transition: transform 0.85s cubic-bezier(0.34, 1.15, 0.64, 1), opacity 0.5s ease;
  pointer-events: none;
  z-index: 2;
}

.search-hand.hand-visible {
  transform: translateY(0);
  opacity: 1;
}

.search-hand-svg {
  width: 100px;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(100, 149, 237, 0.22));
}

@keyframes search-hand-tap {
  0%   { transform: translateY(0);    }
  40%  { transform: translateY(-12px); }
  70%  { transform: translateY(4px);  }
  100% { transform: translateY(0);    }
}

.search-hand.hand-tap {
  animation: search-hand-tap 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.search-anim-caption {
  text-align: center;
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 0.6rem;
}

/* ---- Ritmo de espaciado (3 niveles) ---- */

/* hr: más aire en los separadores entre familias */
hr {
  margin: 2.5rem 0;
}

/* Nivel 1 — Apretado: entre prosa y el card inmediato */
.family-quickfacts {
  margin-top: 0.75rem !important;
  margin-bottom: 0 !important;
}

.decision-tree-figure { margin: 0.75rem 0; }
.fc-diagram.fc-diagram-rl { margin: 0.75rem 0 0.5rem; }

/* Nivel 2 — Medio: headings de familia (h4) */
h4:not(.family-title):not(.demo-title):not(.two-question-card h4):not(.key-moment-headline) {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

/* Nivel 3 — Amplio: headings de sección mayor (h3) */
h3 {
  margin-top: 3rem;
}

/* ---- Dos preguntas del mapa ---- */
.two-question-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.2rem;
}

.two-question-card {
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 18px;
  padding: 1rem 1rem 1rem 1.15rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.two-question-card:hover {
  border-color: rgba(39, 128, 227, 0.28);
  box-shadow: 0 14px 30px rgba(39, 128, 227, 0.07);
}

.two-question-card h4 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--c-navy);
}

.two-question-card p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.62;
  color: #475569;
}

.two-question-num {
  display: block;
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--c-primary);
  opacity: 0.22;
  margin-bottom: 0.35rem;
  user-select: none;
}

/* ---- Ejemplo trabajado (después del mapa de métodos) ---- */
.worked-example {
  background: #f8fbff;
  border: 1px solid var(--c-border-blue);
  border-left: 3.5px solid var(--c-primary);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin: 1.25rem 0 0;
}

.worked-example-label {
  margin: 0 0 0.7rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-primary);
}

.worked-example-steps {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.worked-step {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.6rem;
  align-items: baseline;
}

.worked-step-num {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.worked-step p {
  margin: 0;
  font-size: 0.87rem;
  line-height: 1.55;
  color: #374151;
}

.worked-step-result {
  border-top: 1px solid var(--c-border-blue);
  padding-top: 0.5rem;
  margin-top: 0.15rem;
}

.worked-step-result .worked-step-num {
  color: #6495ED;
}

/* ---- CNN: flujo horizontal bordes→formas→objeto ---- */
.cnn-flow-svg {
  width: 100%;
  max-width: 500px;
  display: block;
  margin: 0.75rem auto 0;
}

/* ---- Transformer: visual de atención ---- */
.transformer-attention-svg {
  width: 100%;
  max-width: 480px;
  display: block;
  margin: 0.75rem auto 0;
}

/* ---- Prompt de reflexión antes de la tabla ---- */
.reflexion-prompt-pre {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.97rem;
  font-style: italic;
  color: #475569;
  padding: 0.75rem 1.1rem;
  border-left: 3px solid #bfdbfe;
  margin: 0 0 1.5rem;
  background: #f8fbff;
  border-radius: 0 10px 10px 0;
}
.reflexion-prompt-pre .reflexion-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  line-height: 1.5;
}
.reflexion-prompt-pre p {
  margin: 0;
}

/* ---- Resumen por familia ---- */
.family-quickfacts {
  --family-accent: #2780e3;
  --family-bg: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid var(--c-border-blue);
  border-radius: 20px;
  padding: 1.1rem;
  background: var(--family-bg);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.05);
  margin: 1rem 0 1.2rem;
}

.family-quickfacts.is-known {
  --family-accent: #0f766e;
  --family-bg: linear-gradient(180deg, #ffffff 0%, #f2fbf8 100%);
}

.family-quickfacts.is-new {
  --family-accent: #6495ED;
  --family-bg: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.family-quickfacts-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 1rem;
}

.family-icon {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 16px;
  font-size: 1.2rem;
  background: color-mix(in srgb, var(--family-accent) 12%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--family-accent) 20%, white);
}

.family-kicker {
  margin: 0 0 0.14rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--family-accent);
}

.family-title {
  margin: 0;
  font-size: 1rem;
  color: var(--c-navy);
}

.family-facts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.family-fact {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  padding: 0.85rem 0.9rem;
}

.family-fact-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--family-accent);
}

.family-fact p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #475569;
}

/* ---- Familia cards (CNN) ---- */
.algo-family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.2rem 0;
}

.algo-family-card {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 18px;
  padding: 1.05rem 1rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.05);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.algo-family-card:hover {
  border-color: rgba(14, 165, 233, 0.34);
  box-shadow: 0 14px 28px rgba(14, 165, 233, 0.08);
}

.algo-family-card.is-new {
  border-color: rgba(39, 128, 227, 0.28);
}

.algo-family-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}

.algo-family-emoji {
  font-size: 1.45rem;
}

.algo-family-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--c-navy);
  margin: 0;
}

.algo-family-analogy {
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.6;
  margin: 0;
}

/* ---- Arbol de decision ---- */
.decision-tree-figure {
  margin: 1.25rem 0;
}

.decision-tree-svg {
  width: 100%;
  max-width: 560px;
  display: block;
  margin: 0 auto;
}

.decision-tree-caption {
  text-align: center;
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 0.5rem;
}

/* ---- K-Means + RL ---- */
.km-cluster-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.km-cluster-tag {
  padding: 0.34rem 0.68rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.24);
  color: #334155;
}

.km-cluster-tags-live {
  margin-top: 0.85rem;
}

.km-cluster-a {
  border-color: rgba(39, 128, 227, 0.2);
  color: #2780e3;
}

.km-cluster-b {
  border-color: rgba(34, 139, 34, 0.22);
  color: #166534;
}

.km-cluster-c {
  border-color: rgba(245, 158, 11, 0.2);
  color: #b45309;
}

.rl-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  align-items: start;
}

.rl-panel {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  padding: 0.9rem;
}

.rl-panel-preview {
  max-width: 320px;
}

.rl-panel h5 {
  margin: 0 0 0.55rem;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #d97706;
}

.rl-metrics {
  display: grid;
  gap: 0.55rem;
}

/* When the panel sits below the canvas (live layout), spread metrics horizontally */
.rl-canvas-frame ~ .rl-panel .rl-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rl-metric {
  border: 1px solid #f1f5f9;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: #fff;
}

.rl-metric-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.rl-metric-value {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--c-navy);
}

.rl-canvas-frame {
  padding: 0.6rem;
  min-height: auto;
}

.rl-canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ---- Actividad interactiva (matching) ---- */
.match-preview-visual {
  padding: 1.2rem 0.5rem;
}

.match-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.match-preview-pill {
  border: 1px solid;
  border-radius: 8px;
  padding: 0.5rem;
  text-align: center;
}

.match-preview-pill-didi {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.match-preview-pill-spam {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.match-preview-pill-spotify {
  background: #fdf4ff;
  border-color: #e9d5ff;
}

.match-preview-pill-video {
  background: #fef3c7;
  border-color: #fde68a;
}

.match-preview-pill-translate {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.match-preview-pill-bot {
  background: #fdf2f8;
  border-color: #f9a8d4;
}

.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.match-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.match-card:hover {
  border-color: rgba(14, 165, 233, 0.34);
  box-shadow: 0 12px 24px rgba(14, 165, 233, 0.08);
}

.match-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.match-card-emoji {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.match-card-title {
  font-size: 0.87rem;
  font-weight: 700;
  color: var(--c-navy);
  margin: 0;
  line-height: 1.35;
}

.match-card-context {
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.match-algo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}

.match-algo-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  padding: 0.3rem 0.25rem;
  font-size: 0.68rem;
  cursor: pointer;
  transition: all 0.14s;
  text-align: center;
  line-height: 1.3;
}

.match-algo-btn:hover {
  background: rgba(100, 149, 237, 0.12);
  border-color: rgba(100, 149, 237, 0.4);
}

.match-algo-btn.is-selected {
  background: #2780e3;
  color: #fff;
  border-color: #2780e3;
}

.match-card.match-correct {
  border-color: rgba(34, 197, 94, 0.55);
  background: #f0fdf4;
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.1);
}

.match-card.match-incorrect {
  border-color: rgba(239, 68, 68, 0.5);
  background: #fef2f2;
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.08);
}

.match-feedback {
  margin-top: 0.7rem;
  font-size: 0.77rem;
  line-height: 1.55;
}

.match-feedback-ok {
  color: #16a34a;
  font-weight: 600;
  display: block;
  margin-bottom: 0.2rem;
}

.match-feedback-err {
  color: #dc2626;
  font-weight: 600;
  display: block;
  margin-bottom: 0.2rem;
}

.match-feedback-limit {
  color: #92400e;
}

/* ---- Tabla comparativa ---- */
.tabla-comparativa-wrap {
  overflow-x: auto;
  margin: 1.2rem 0;
}

.tabla-comparativa {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.tabla-comparativa th {
  background: #1a365d;
  color: #fff;
  padding: 0.55rem 0.7rem;
  text-align: left;
  font-weight: 600;
}

.tabla-comparativa td {
  padding: 0.56rem 0.7rem;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.tabla-comparativa tr:nth-child(even) td {
  background: #f8fafc;
}

.tabla-comparativa tr:hover td {
  background: #eff6ff;
}

.tag-nuevo,
.tag-conocido {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 99px;
  margin-left: 0.3rem;
  vertical-align: middle;
}

.tag-nuevo {
  background: #eff3fd;
  color: #6495ED;
}

.tag-conocido {
  background: #d1fae5;
  color: #065f46;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .two-question-grid,
  .family-facts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .algo-family-grid,
  .match-grid {
    grid-template-columns: 1fr;
  }

  .match-algo-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .match-preview-grid {
    grid-template-columns: 1fr;
  }

  .family-quickfacts,
  .two-question-card {
    padding: 0.95rem;
  }

  .rl-canvas-frame ~ .rl-panel .rl-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---- K-Means: Spotify Wrapped–style tag reveal ---- */
@keyframes km-tag-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.78); }
  to   { opacity: 1; transform: none; }
}

.km-cluster-tags-live .km-cluster-tag {
  animation: km-tag-pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .match-card,
  .algo-family-card,
  .two-question-card,
  .km-cluster-tags-live .km-cluster-tag,
  .search-hand,
  .search-caret {
    animation: none !important;
    transition: none !important;
  }
}
